The default WordPress cron (wp-cron.php) handles automated tasks for websites built with WordPress. This type of cron is only triggered if somebody visits your website. So, for example, if you scheduled a post and you did not install any post-scheduling plugin, your post might not be published on time if nobody visits your website at your scheduled time. And if your website has a lot of automated features and it receives lots of traffic, there will also be a lot of calls to the wp-cron.php file, which can have an impact on your web server resources. This tutorial will teach you how to use Cron Jobs, which is available in cPanel, instead of the default WordPress cron.
1. Go to your WordPress installation folder and look for the file wp-config.php.
2. Open the wp-config.php file and look for the line below:
/* That's all, stop editing! Happy publishing. */
3. Add the code below right above the line in Step 2.
/** Disable default WordPress cron */ define('DISABLE_WP_CRON', true);
4. Save the file.
5. Go to the cPanel of your web host.
6. Scroll down the page to the Advanced section.
7. Click on Cron Jobs.
8. Go to the Add New Cron Job section.
9. Set Common Settings to Twice an Hour (0,30 * * * *).
This will run the cron every 30 minutes instead of every time your website has a visitor. Most web hosts do not want this set to lower than 15 minutes.
10. In Command, enter the line below:
wget -q -O - https://example.com/wp-cron.php?doing_wp_cron >/dev/null 2>&1
Do not forget to use your actual domain name and include the name of your WordPress installation folder (if you installed WordPress in a subdirectory).
11. Click on the Add New Cron Job button.