benphelps Posted June 3, 2009 Share Posted June 3, 2009 I have the code below, and it runs just fine, no errors, no warnings. But when I set it in a cron job, it fails, no idea why. <? ## include, few vars are set and mysql connect stuff here $result = mysql_query("WORKING MYSQL QUERY"); while($row = mysql_fetch_array($result)){ if ( ($row['last']+$row['int']) < time()+5 ){ $send = $row['id']; exec("php fork.php \"${send}\" > /dev/null &"); } } ?> fork.php has no problems, and works fine Quote Link to comment https://forums.phpfreaks.com/topic/160846-solved-script-not-running-when-executed-with-cron/ Share on other sites More sharing options...
Alex Posted June 3, 2009 Share Posted June 3, 2009 I believe I read something about the paths for things on CRON files have to be different because of the way they're ran. So try making them in terms of the root, eg. instead of fork.php try ../whatever/fork.php (or however yours is setup). However, if that fails I also encountered a similar problem with CRON and a php script utilizing MySQL, which I wasn't even including anything on.. and I still couldn't get it to work. It was strange. Quote Link to comment https://forums.phpfreaks.com/topic/160846-solved-script-not-running-when-executed-with-cron/#findComment-848889 Share on other sites More sharing options...
benphelps Posted June 3, 2009 Author Share Posted June 3, 2009 It was the path. Would have never caught that on my own, thanks. Quote Link to comment https://forums.phpfreaks.com/topic/160846-solved-script-not-running-when-executed-with-cron/#findComment-848901 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.