This article describes how to configure a cron job for WordPress.
A cron job is a task scheduled to run automatically at specific intervals. For example, a cron job could automatically back up a file every six hours.
In its default configuration, WordPress does not use a real cron job for scheduling and other related tasks. Instead, whenever a page is loaded on a WordPress site, WordPress runs the wp-cron.php file. Although this “virtual” cron job is convenient, it has a few disadvantages:
To resolve these issues, you can disable the default virtual WordPress cron job, and configure a real cron job. To do this, follow the procedures below.
To disable the default virtual WordPress cron job, follow these steps:
define('DISABLE_WP_CRON', true);
Make sure you add the previous line before the following line in the wp-config.php file:
/* That's all, stop editing! Happy publishing. */
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, or use the A2 Optimized plugin for WordPress.
To set up a WordPress cron job using cPanel, follow these steps:
cd ${HOME}/public_html; php -q wp-cron.php
To set up a WordPress cron job using the command line, follow these steps:
crontab -e
Type the following line, replacing username with your own A2 Hosting account username:
*/30 * * * * cd ${HOME}/public_html; php -q wp-cron.php
The A2 Optimized plugin enables you to quickly and easily disable the virtual WordPress cron and enable a system cron instead.
To enable a system cron job for WordPress using the A2 Optimized plugin, follow these steps:
Click the Optimization tab:
In the Use System Cron Instead of WordPress Cron section, click the slider to enable the option, and then click Update. A2 Optimized disables the WordPress virtual cron and creates a system cron job:
Subscribe to receive weekly cutting edge tips, strategies, and news you need to grow your web business.
No charge. Unsubscribe anytime.
Did you find this article helpful? Then you'll love our support. Experience the A2 Hosting difference today and get a pre-secured, pre-optimized website. Check out our web hosting plans today.
We use cookies to personalize the website for you and to analyze the use of our website. You consent to this by clicking on "I consent" or by continuing your use of this website. Further information about cookies can be found in our Privacy Policy.