The joys of following directions (cron.php edition)

Quick note to myself that it is worth following the actual directions for setting up cron over at http://drupal.org/cron, instead of just a rough approximation. I have been doing

30 * * * * /usr/local/bin/wget http://my.site.com/cron.php >& /dev/null

And have always been a little annoyed at the accumulation of cron.php.X files in my home directory, but never annoyed enough to figure it out.

Turns out wget really wants to save a file with the web content. Sending the content to /dev/null doesn't stop it. wget just happily creates an empty file. That is why the drupal.org docs helpfully suggest:

30 * * * * /usr/local/bin/wget -O - -q -t 1 http://my.site.com/cron.php

-O - = Don't create a new file, instead send results to to standard output.
-q = quiet. This turns off the standard output (clever, eh?).
-t 1 = Only try once.

I've been growing more fond of CURL recently

The default action is to print to stdout, and it's also available in PHP as a library.

Thanks for pointing this

Thanks for pointing this out. I too have fallen victim to not being annoyed enough to figure out the correct way to hit the cron.php file. I always wondered why sending the download to /dev/null wasn't working, but never took the time to look. Thanks for taking the time to blog about it.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.