westman Posted March 22, 2018 Share Posted March 22, 2018 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 More sharing options...
justsomeguy Posted March 22, 2018 Share Posted March 22, 2018 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 More sharing options...
westman Posted March 23, 2018 Author Share Posted March 23, 2018 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 More sharing options...
justsomeguy Posted March 23, 2018 Share Posted March 23, 2018 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 More sharing options...
westman Posted March 23, 2018 Author Share Posted March 23, 2018 I have nothing in my error log. How do I forces my cron job to log all actions using my cron job command? Link to comment Share on other sites More sharing options...
justsomeguy Posted March 23, 2018 Share Posted March 23, 2018 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 More sharing options...
westman Posted March 23, 2018 Author Share Posted March 23, 2018 I don't know what happened but I sent the cron job to run every hour and it works fine. Now I am going to test it for daily as that is what I need. Link to comment Share on other sites More sharing options...
westman Posted March 23, 2018 Author Share Posted March 23, 2018 hourly is working fine but just tested daily and it is not working. Why? Link to comment Share on other sites More sharing options...
justsomeguy Posted March 23, 2018 Share Posted March 23, 2018 I've already told you how to debug this, my answer hasn't changed. 99% of these issues are with the PHP code, and you use an error log. If you think there's a problem with cron contact your host. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now