The thoughts of Matthew Crist, a designer in Boston.

Jan 11, 2015

Disabling WP-Cron for a Faster Wordpress

Wordpress has this one file called wp-cron.php that runs every time someone visits your site. This is basically a hack that allows Wordpress and any plugin to run processes on a schedule.

The downside is that it runs on every visit. I’m sure that’s performant.

Rather than letting wp-cron slow down your site, it should be disabled and let your system handle scheduled processes in the background — as it should.

Disabling wp-cron can be done by adding this line in your wp-config.php file.

define('DISABLE_WP_CRON', 'true');

With a disabled wp-cron, you’ll need to setup cron to run in the background. This can be done a couple of different ways.

Hosting Control Panel

Your hosting provider may provide a control panel that allows you to setup cron jobs. If you have access to this, you can enter this command for cron to run:

php -f /path/to/wp-cron.php > /dev/null

This will run wp-cron.php on the schedule that you determine.

Shell Via SSH

If you’re feeling savvy, you can log into your hosting account via SSH and edit your cron jobs manually. To get started, login to your host via SSH. Then edit your cron config with:

crontab -e

This will open an editor to add commands. Add this line:

*/30 * * * * php -f /path/to/wp-cron.php > /dev/null

This will run wp-cron.php every 30 minutes in the background without any affect on the performance of your site.