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..
LVL 1
XK8ERAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

15 00 * * *  pathToJob

change "pathToJob" to the name of the script

will run at 12:15 am everyday


Cd&
0
XK8ERAuthor Commented:
you guys dont understand what im trying to accomplish..
0
OWASP: Avoiding Hacker Tricks

Learn to build secure applications from the mindset of the hacker and avoid being exploited.

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 ..
0
XK8ERAuthor Commented:
**12:15am and it finished at 12:18am
0
Dave BaldwinFixer of ProblemsCommented:
Cron isn't going to do that for you.
0
COBOLdinosaurCommented:
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.


Cd&
0
xtermCommented:
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() {
        $job="/tmp/.at-plus-24";
        $jp=fopen($job,"w");
        fputs($jp,"/full/path/to/my/php/script");
        fputs($jp,"rm -f $job\n");
        fclose($jp);
        $currtime=date("U");
        $relutime=$currtime+86400;
        $reltime=date("YmdHi",$relutime);
        exec("at -f $job -t $reltime");
}

schedule_next_run();

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
XK8ERAuthor Commented:
just amazing xterm!! glad to see useful coders here on EE.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.