X

Disable WordPress Crontab and Run it Manually

By default WordPress runs wp-cron.php every time  someone visits your site. This causes increased load on the server each time a page is requested. On low traffic sites this really isnt noticeable but on higher traffic sites this can become problematic and cause increased load and resource consumption on the server.

Turn off the WordPress Crontab

SSH to the server and go to the base install path of your install.

Open wp-config.php and add the following line to the bottom of the file

define('DISABLE_WP_CRON', 'true');

After saving the file, wordpress will no longer execute the crontab each time a new request for a page is issued.

Add a Manaul Crontab

edit the user crontab by typing

crontab -e

and add the following line:

15 * * * * /path/to/php /path/to/wordpress/wp-cron.php

You will want to  substitute in the following:

/path/to/php with the path to binary php. You can find this by doing

# which php
 /usr/local/sbin/php

/path/to/wordpress/ with the full path to your  install.

The crontab can be scheduled on how often you want it to run. Its currently setup to run once an hour on the 15 minute increment.  It could alternatively be scheduling using a wget or curl method as well.

LinuxAdmin.io
0 0 votes
Article Rating
LinuxAdmin.io:
Related Post