How to disable wp-cron.php in WordPress?
wp-cron.php is a file used by WordPress as a virtual cron job. Crons are used to run scheduled task in order to automate things like publishing scheduled posts, checking for plugin or theme updates, sending email notifications and more.
WordPress is setup by default to call wp-cron.php everytime someone visits your WordPress website. This means with every website visit, wp-cron.php is checking to see if there is a scheduled task present, to basically ask itself to see if there anything it needs to do.
On low traffic websites this is perfectly fine, but when your site visits start to increase, checking multiple times for scheduled tasks can be very inefficient and lead to resource usage problems for the server, this will eventually make your website load slower.
For advanced usage, WordPress has made a way to disable wp-cron.php from running with every website visit. Advanced users should take advantage of that and disable default WordPress settings for wp-cron.php and enable a more advanced option. For most WordPress users having the wp-cron.php script run every 12 hours is perfectly fine. That would be just 2 executions in a day, compared to possibly hundreds, or even thousands if you had a lot of website traffic that day.
Disable default wp-cron.php behavior
- Open your wp-config.php file with the cPanel File Manager Code Editor
- Go to the bottom of the database settings in wp-config.php typically around line 37.
- Add the following code, and Click Save:
Setup manual system cron job for WordPress wp-cron.php on cPanel
- Log into cPanel
- Click on cron jobs Under the Advanced section, click on Cron Jobs.
- Select Once an hour from the Common Settings drop-down.
- Now select Every 12 hours from the Hour drop-down.
- Finally fill in the command and arguments below to run the cron job.
- Click Add New Cron Job.
Path "/home/username/public_html" should be replaced by the location of your WordPress installation.
Keep in mind that the "/home/username/public_html" path would be for a primary domain, if you're using an addon domain, or have WordPress installed in a sub-directory you'll want to be sure to update your path to the correct one.
You should see that your new cron job was added successfully.
Now WordPress should be safely running scheduled tasks via the wp-cron.php script, but only at set intervals.