setup conrjob for php

hello there,
I have a little php script that is ran every 5 minutes from cronjob..
I would like to know how can I make something so that its ran every 24 hours..

for example:
there is a log file that says "Finished at 12:13am" then when cron hits 12:15am it should run the script..
the php script usually takes 3 minutes to finish running so when its done it should write "Finished at 12:18am"..
im trying to make a cronjob that can run about 2 minutes after 24hrs..
I know how to setup the cronjob to run every 5 minutes I need help and ideas with the php code..
Who is Participating?
xtermConnect With a Mentor Commented:
Cron isn't dynamic, but your script can be.   Add this function to your script, and call it at the end.  It will automatically schedule itself to run again in exactly 24 hours after it completed.

It needs to be run as root, and it will need to be run manually the first time (or kicked off by a temporary cron if you like) but you will need to remember to start it again after reboots too.

If you want it to run after 24 hrs and two minutes instead of 24 hrs, change 86400 to 86520.

Be sure to edit the function to reflect the exact location of your php script.
function schedule_next_run() {
        fputs($jp,"rm -f $job\n");
        exec("at -f $job -t $reltime");


Open in new window

Dave BaldwinFixer of ProblemsCommented:
The cronjob sets the timing, not the PHP.
In crontab put

15 00 * * *  pathToJob

change "pathToJob" to the name of the script

will run at 12:15 am everyday

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

XK8ERAuthor Commented:
you guys dont understand what im trying to accomplish..
XK8ERAuthor Commented:
if I run the php script at 12:15am and it finished at 12:18pm and then I run it at 12:15am the next day then its 23 hours and 57 minutes.. not 24 hours..
that why I need it to run at 12:15am then 12:20 the next day then 12:25 the next so on ..
XK8ERAuthor Commented:
**12:15am and it finished at 12:18am
Dave BaldwinFixer of ProblemsCommented:
Cron isn't going to do that for you.
Cron is not dynamic.  You tell it when and it does the job but it has to be a hard value there are no variables in cron.

XK8ERAuthor Commented:
just amazing xterm!! glad to see useful coders here on EE.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.