Monday, January 18, 2010

Why your cron job doesn't execute

If you set up your cron, and it looks like the cron doesn't execute, here are some reason and how to solve:

- You set wrong time setting

Sometimes people asked me why their cron jobs don’t execute, or execute only one time. When I checked the cron setting, I saw that they set Hour or Day field to "1", and expect it to run every "1" hour/day. The correct time setting to make it run hourly or daily is set the Hour or Day field to "All", and set a specific value for the smaller field: Minute and/or Hour.

You are recommended to create cron job at a predefined interval. Just click on "Create new cron jobs" and see the instructions.

- It's not time to execute.

The value "Every X" means that your cron will be executed when the field is divisible by X. For example, if you set the hour to Every 6, your cron job will be executed at 0, 6, 12, 18 o'clock.

And the time zone of SetCronJob is GMT/UTC, so don't look at your clock or watch, look at the bottom of Control Panel and see what time it is in GMT/UTC.

- The connection/request failed.

You can set the Notify value to Failure, so that you will receive notification when SetCronJob is unable to make a connection and request.

-Your script is deleted / redirected.

If it used to work before, but suddenly stopped work, you should check your script. Try entering the URL into your favorite browser (FireFox, IE, Opera, etc). If it has been deleted, you may see the error HTTP 404 Not Found. If it's redirected to somewhere, e.g. to www or non-www version, try setting cron with destination URL.

- Your cron job is disabled.

Check the Status field of your cron whether it's "Active" or not. If it's disabled, try enabling it by click on Edit icon, then Save icon.

- Your script is executed, but not works.

If your script is executed by my bot (see the logs, or set Notify to Always, or add some sending mail snippet to your script, etc), but it doesn't work and does its jobs, you'd better have a look at your script.

If it's a URL to some cron file created by another script, e.g. CMS (Drupal, Joomla, etc), forums, blog (WP-o-Matic of WordPress, etc), you should re-check its settings, or ask your friends who have experience on that software.

If it's your own script, you can check whether it works correctly when being called from a browser. Try checking whether there's some syntax or logic error.

If your script partially executed, consider tips at Set up cron jobs with PHP script. I'm sure it will help you :)

 

If you are sure your cron script, time setting are ok, but SetCronJob doesn't execute your cron, don't hesitate to contact me.

 

No comments:

Post a Comment