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
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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.