Beauford Posted March 27, 2009 Share Posted March 27, 2009 I'm really hoping someone can help on this one as I don't have a clue what is going on. I have a small PHP script which I am running as a cron job that updates a couple of MySQL tables in my DB. I know the cron is being run at the correct time as I have had it write several small text files and all is ok there. The problem is this, none of the code in the script gets executed. So your first thought would be - debug the code. Well, here's the other side of the puzzle. If I go to my browser and run the script manually from there, it works perfectly every time and everything gets updated the way it should be. So what are some reasons that manually it works, and from the cron it does not. I don't get it. Thanks for any input. Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted March 27, 2009 Share Posted March 27, 2009 Code? What does the cronjob command line look like? Can you run the script manually from the command line? Ken Quote Link to comment Share on other sites More sharing options...
thepip3r Posted March 27, 2009 Share Posted March 27, 2009 i would be willing to bet (based off of what you said) that its' because you're using functions that only work in the web environment. specifically, echo and print. if my memory serves, when i wrote a "php script" to run outside of the web environment, there will very different output functions to use -- your script may be failing on echo's and prints or some other web-dependent functions and depending on your reporting, you may not be seeing them. Edit: http://us2.php.net/manual/en/features.commandline.php Quote Link to comment Share on other sites More sharing options...
Beauford Posted March 28, 2009 Author Share Posted March 28, 2009 Cron: 5 * * * * /directory_path/cron_hour.php No functions - other than a mysql class, no prints, no echos. I have 5 other crons setup the same way that run fine. As I said, runs perfect every time from the command line. Thanks Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted March 28, 2009 Share Posted March 28, 2009 Echo and print work fine from the command line. I use them all the time. Try setting up your crontab entry like 5 * * * * php -q -f /directory_path/cron_hour.php If using "php" by itself use the path to php. Ken Quote Link to comment 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.