Hey guys,
I am wondering if any of you have faced this situation before.
I have multiple cron files setup to run at a specific time. Lets say each day at midnight. It's important that they all run within the same minute not 1 minute after the hour or 1 minute before the hour.
Lets say I have 1 cron file update all the players stats for the previous day such as number of employees. Next I would want a separate cron file run to update the records/high scores which would need to reference the data updated from the previous cron file.
Is there a way to force 1 cron file to run/complete before the next cron file within the same 1 minute time frame?
Any suggestions are greatly appreciated.
Help with cron jobs
Help with cron jobs
if( $myGames != "Crap" ) {
- please_donate( $money );
- just_enjoy();
- hallsofvallhalla
- Site Admin
- Posts: 12023
- Joined: Wed Apr 22, 2009 11:29 pm
Re: Help with cron jobs
put your second cron into a function in another page and include the page and call that function at the end of the first cron.
If you really want to separate them then you could put a flag in the DB that marks when the file has started and when it finishes. Then check it on the second cron. You will then need to run the cron more often in case the first time it fails.
If you really want to separate them then you could put a flag in the DB that marks when the file has started and when it finishes. Then check it on the second cron. You will then need to run the cron more often in case the first time it fails.
Re: Help with cron jobs
Thanks for the help - This sounds like an excellent solution.hallsofvallhalla wrote:put your second cron into a function in another page and include the page and call that function at the end of the first cron.
If you really want to separate them then you could put a flag in the DB that marks when the file has started and when it finishes. Then check it on the second cron. You will then need to run the cron more often in case the first time it fails.
Do you know if crons have a max execution time - and if they do - would you recommend doing something like: set_time_limit(0) inside the cron file?
if( $myGames != "Crap" ) {
- please_donate( $money );
- just_enjoy();