Sinikka Posted October 16, 2007 Share Posted October 16, 2007 Hi I'm pretty new at this so sorry if I don't come across to clearly. I'm having a problem with a cron, instead of executing the cron every 15 minutes like it's supposed to it's setting the last run for each job like it already executed and bypassing it. Here's the query that's not working correctly. $dailyCron = mysql_query("SELECT * FROM cron WHERE game = '$game' AND weekly_run = '0' AND monthly_run = '0' AND (last_run is null or last_run != now())"); while ($getDailyCron = mysql_fetch_array($dailyCron)) { $explodeCronTime = explode(":", $getDailyCron[cron_time]); $cronHour = $explodeCronTime[0]; $cronMin = $explodeCronTime[1]; if ($cronHour > 12) { $cronHour -= 12; } if (($cronHour < $hour2) or ( $cronHour == $hour2 AND $cronMin <= $minute)) { $cronName = $getDailyCron[cron_name]; $run[$cronName] = 1; mysql_query("UPDATE cron SET last_run = now() WHERE game = '$game' AND id = '$getDailyCron[id]'"); mysql_query("UPDATE cron SET total_runs = total_runs + 1 WHERE game = '$game' AND id = '$getDailyCron[id]'"); } } Quote Link to comment https://forums.phpfreaks.com/topic/73486-solved-cron-issue/ Share on other sites More sharing options...
Sinikka Posted October 17, 2007 Author Share Posted October 17, 2007 Bump Quote Link to comment https://forums.phpfreaks.com/topic/73486-solved-cron-issue/#findComment-371293 Share on other sites More sharing options...
Branden Wagner Posted October 17, 2007 Share Posted October 17, 2007 1. Can you give me an Example row of what the query would return? 2. What is the purpose of the script? and maybe i can come up with something a little different with the same general idea Quote Link to comment https://forums.phpfreaks.com/topic/73486-solved-cron-issue/#findComment-371318 Share on other sites More sharing options...
Sinikka Posted October 17, 2007 Author Share Posted October 17, 2007 The purpose of the script is to restock items in shops in an online game. The script is supposed return the row where cron_time matches the current time and then execute the corresponding program. Quote Link to comment https://forums.phpfreaks.com/topic/73486-solved-cron-issue/#findComment-371327 Share on other sites More sharing options...
Sinikka Posted October 17, 2007 Author Share Posted October 17, 2007 bump Quote Link to comment https://forums.phpfreaks.com/topic/73486-solved-cron-issue/#findComment-371765 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.