To disable the default virtual WordPress cron job, follow these steps:
-
Using the cPanel File Manager or the command line, open the wp-config.php file in a text editor.
Note
The wp-config.php file is located in the directory where you installed WordPress. Usually, this is the public_html directory.
-
Add the following line to the wp-config.php file:
define('DISABLE_WP_CRON', true);Important
Make sure you add the previous line before the following line in the wp-config.php file:
/* That's all, stop editing! Happy publishing. */ -
Save the changes to the wp-config.php file and then exit the text editor. The virtual WordPress cron job is now disabled.
Configuring a real cron job for WordPress
After you have disabled the default WordPress cron configuration in the wp-config.php file, you are ready to set up a real cron job that runs at fixed intervals regardless of site traffic.
If your account includes cPanel access, you can use it to configure the cron job. Alternatively, you can configure the cron job from the command line.
To set up a WordPress cron job using cPanel, follow these steps:
-
Log in to cPanel.
-
In the Advanced section of the cPanel home screen, click Cron jobs.
-
Under Cron Email, type the e-mail address that you want to receive notifications, and then click Update Email. Every time the cron job runs, the e-mail account will receive a message.
Note
If you do not want to receive e-mail notifications for the cron job, you can append >/dev/null 2>&1 to the command, which redirects all output to /dev/null .
-
Under Add New Cron Job, in the Common Settings list box, select Twice an hour.
Note
You can run cron jobs a maximum of every 15 minutes on shared and reseller accounts. A 30-minute interval for the WordPress cron job should be more than sufficient.
-
In the Command text box, type the following line:
cd ${HOME}/public_html; php -q wp-cron.phpNote
This line assumes that you installed WordPress in the document root (public_html ) directory. If you installed WordPress in another directory, modify the cd command to change to that directory instead.
-
Click Add New Cron Job. The new cron job settings take effect immediately.
To set up a WordPress cron job using the command line, follow these steps:
-
Log in to your account using SSH.
-
At the command prompt, type the following command:
crontab -e -
Type o to enter editing mode and start a new line of text.
-
Type the following line, replacing username with your own hosting.com account username:
*/30 * * * * cd ${HOME}/public_html; php -q wp-cron.phpNote
-
This line sets the cron job to run every 30 minutes. If you are on an unmanaged platform you can run cron jobs as frequently as you want. On shared and reseller accounts, however, you can only run cron jobs a maximum of every 15 minutes. A 30-minute interval for the WordPress cron job should be more than sufficient.
-
This line assumes that you installed WordPress in the document root (public_html) directory. If you installed WordPress in another directory, modify the cd command to change to that directory instead.
-
-
Press Esc, type
:wqand then press Enter. The new cron job settings take effect immediately.