Your Wordpress installation is constantly working in the background, and uses a plethora of systems to help manage site operations. One of these are WP-crons, which are used to executes specific tasks for any Wordpress powered site. The WP-cron.php file is located in your main Wordpress folder for your site files and is executed every time a visitor loads a page. This file then checks if there is any scheduled tasks to be ran and executes it if necessary. This is used for multiple things from checking for updates, to plugins using the cron job to carry out specific tasks. For example any backup plugin that automatically creates backups at any given schedule is operating from a WP-cron.
Although this is a very convenient process, there can be multiple issues or complications that could potentially cause the WP-cron to fail such as:
- Conflicting with active plugins.
- Wordpress bugs
- Issues related to DNS
On top of these possible issues, WP-Cron doesn't run continuously and could potentially be an issue for any critical tasks that are scheduled. In some cases caching plugins can also conflict with the file execution and cause a large server load or the scheduled tasks could be delayed or not execute at all. The best resolution for this would be to substitute the WP-Cron with a real cron job.
The first step to replacing the WP-Cron is to disable the file by modifying the wp-config.php file, which is located in the folder where your Wordpress is installed. Once in the file your going to add the following code before the "/* That's all, stop editing! Happy blogging. */" line:
After the WP-Cron is disabled, the next step is to setup the real cron job which would vary depending on you server type. As all of Create's servers are Linux, we will specifically be going through how to setup a Linux cron job.
- First you'll need to log into your cPanel the site content is on.
- In the Advanced section of icons, click Cron Jobs.
3. Under Add New Cron Job, select the desired time interval. Here at Create we recommend that the interval is not set lower than 15 minutes, 30 minutes is typically fine for most websites.
4. Next in the Command field set the following code, replacing yourwebsite.com with your actual domain name:
wget -q -O - http://yourwebsite.com/wp-cron.php?doing_wp_cron >/dev/null 2>&1
5. Click Add New Cron Job to set you new cron job.