Jump to content

Cron job stopped working


westman
 Share

Recommended Posts

Hi there,
I made a cron job on godaddy and it worked for the first two days and now it is no longer working.
Here is my code.

 

0 10 * * * /usr/local/bin/php -q /home/mysite/public_html/scripts/cron_day.php

 

Why did it stop working?
What did I do wrong?

Link to comment
Share on other sites

I imagine the actual cron job is still running to execute that code, so you need to debug the code that it's running.  Make sure that PHP script is using an error log that you can check for error messages to look for problems when it ran.  Make sure you also test that code to make sure it does what you think it does.  Ideally you would run that actual command in the shell.

Link to comment
Share on other sites

I put mysite/public_html/scripts/cron_day.php in my browser to run the code.
It worked with no problem.
I even looked for errors with this code

error_reporting(E_ALL); 
ini_set('display_errors', '1');

There are no errors with the php file.
The cron job itself is not working.
Why?

Link to comment
Share on other sites

Well, maybe you're using parts of PHP that only work in a web server and not when you just run the file directly on the command line.  Maybe there are any number of possible runtime errors.  I don't know, I haven't seen the code you're trying to run.  It's not going to do any good to have it display error messages when you're not running the file yourself.  Make it use an error log, make sure PHP has write access to the error log, and check the error log after the cron job runs.

If you think the actual problem is cron, and not your PHP code, then your server is fundamentally broken in such a way that something as basic as cron doesn't even work and you need to reinstall Linux.  I bet that has nothing to do with it though, and that the problem is your PHP code.

Link to comment
Share on other sites

I don't know what GoDaddy allows, my servers let me email the output of a cron job if there is any (which would be the only reason to have PHP display error messages from a cron job).  Check with GoDaddy to see what your options are.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...