Fix WordPress “Missed schedule” error on Media Temple (dv) / Plesk

After a lot of debugging, I was able to figure out that Media Temple’s (dv) configuration was responsible for the “Missed schedule” errors I was getting in WordPress.  By default, the /etc/hosts file looks like this:

127.0.0.1  yourdomain.com yourdomain localhost localhost.localdomain

To execute cron tasks, WordPress needs to post to the URL http://yourdomain.com/wp-cron.php?doing_wp_cron. This isn’t usually a problem, but with the above hosts file and Plesk’s Apache configuration, that URL will actually result in a 404 error.

I tried removing yourdomain.com and youdomain from the hosts file:

127.0.0.1  localhost localhost.localdomain
Unfortunately, when you restart the VPS using Virtuozzo in Plesk, yourdomain.com and yourdomain will just be added back in.  However, after some exhausting Google searching I found out that you can just move them down to the next line with the proper IP address:
127.0.0.1  localhost localhost.localdomain
xxx.xxx.xxx.xxx yourdomain.com yourdomain

Now when you restart the VPS, these changes to the hosts file will remain.

I looked at several other possible solutions to fix the “Missed schedule” problem.  One solution was setting the “ALTERNATE_WP_CRON” constant in the wp-config.php:

define('ALTERNATE_WP_CRON', true);

This activated some very messy redirecting for the user as they browsed the site though.  Not a great solution.  Another solution I was considering was just executing wp-cron.php from a cronjob every hour. Something like this:

0 * * * * /home/yourdomain/htdocs/wp-cron.php >/dev/null