This constant just enables or disables the check for events that are ready to fire. You still
add and manage events as we did up above. We just need to manually hit the wp-cron.php
file in our WordPress install often enough to fire our scripts when needed.
If all you have are daily scripts, you can add a cron job like this via the crontab -e
command:
0 0 * * * wget -O - -q -t 1
http://yoursite.com/wp-cron.php?doing_wp_cron=1
Information on how to use cron can be found at its Wikipedia entry. Information on
how to use wget can be found at the wget manual.
The 0 0 * * *
part of the preceding entry tells cron to execute this script at 0 minutes
on the 0th hour (midnight) every day of the week.
The wget -O - -q -t 1 http://yoursite.com/wp-cron.php?doing_wp_cron=1
part
uses the wget command to load up the wp-cron.php page in your WordPress install. The
-O
- tells wget to send output to devnull, and the -q
enables quiet mode. This will keep
cron from adding files to your server or emailing you the outputs of each cron run. The
-t 1
tells cron to try once. This will keep wget from hitting your server multiple times
if the first try fails. If the call to wp-cron.php
is failing, the rest of your website is probably failing too; hopefully you’ve already been notified.
Be sure to change yoursite.com
to your actual site URL. And finally, the ?doing_wp_cron=1
on the end of the URL is needed since wp-cron.php will check for that
$_GET
parameter before running.