How to fix cron.php fail with 404 error?

Pick Language to Auto Translate:
AR | BG | CA | CS | DA | DE | EL | ES | FI | FR | HI | HR | ID | IT | IW | JA | KO | LT | LV | NL | NO | PL | PT | RO | RU | SK | SR | SL | SV | TL | UK | VI | ZH | ZH-TW

The causes of cron.php fail with 404 error has a lot of theories but the one that I found work for me is "clear cached data". You might also get "Cron job fail" when to try to run manually!

Here is how to do "clear cached data":
. Click on "Administer", then click on "Performance" and scroll toward the bottom you will find "Clear Cached Data" button, click on it.

This will clear any previously log cron.php related error which might cause your cron.php to fail and return with 404 error. This will take care of the failure but what might cause it to be like that from time to time!

Since the cron.php is web accessible anyone can just try to run cron.php and give you a DoS which might cause cron.php to get into this situation so you need to secure your cron.php by way of .htaccess

Here is a sample code that you can use to add to your Drupal .htaccess to only allow running Drupal cron.php from your localhost and your IP.

Order Deny,Allow
Deny from all
Allow from localhost
Allow from
# Allow from xx.xx.xx.xx

In case you are looking for sample on how to run cron.php here are some samples:

lynx -source
PHP -q /home/username/www/drupal/cron.php

Here is a sample what you would enter into crontab to send email and cron.php every two hours

crontab -e

*/120 * * * * wget