Jump to content

PHP and Cron Jobs. Weird Problem!!


Beauford

Recommended Posts

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.

 

Link to comment
https://forums.phpfreaks.com/topic/151459-php-and-cron-jobs-weird-problem/
Share on other sites

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.