The following is a step-by-step guide to replacing WordPress cron jobs on Plesk. When you have finished, WordPress scheduled actions will run reliably and efficently thanks to being triggered by a real server cron job.
By default, WordPress cron relies on someone visiting the site to be triggered. As such, scheduled actions only run if the site has traffic. The flip side of this is that it runs every time a visitor hits the site.
Before setting up the server to run the scheduled actions, we need to stop WordPress’ default cron system. We do this by defining DISABLE_WP_CRON as TRUE in our wp-config.php file.
Log in to your Plesk admin panel and go to the site you want to setup real cron for.
Go to the File Manager and navigate to the site’s root directory that has wp-config.php in it and open the file.
Open up the file wp-config.php in the File Manager to make the alterations.
Below the line that says
Add the following PHP code snippet
So your wp-config.php looks like
define('WP_DEBUG', FALSE); define('DISABLE_WP_CRON', true);
WordPress cron will no longer try to trigger the scheduled actions list when visitors are active on the site. We can instead configure our Plesk server to do this for us.
Now we can give our Plesk server the duties of running the WordPress scheduled actions.
The process to getting Plesk to run WordPress cron jobs is quite simple and it’s a single command in Plesk’s scheduled tasks system.
Go back to your domain’s main control panel in Plesk. In the sidebar, look for the Scheduled Tasks link and go to it.
Click Add Task. This will open up the Scheduled Tasks control panel where we will create our cron job.
Fill in the form with the following settings
|Task Type||Select Run a command|
|Command||wget -q -O – http(s)://yourdomain.com/wp-cron.php?doing_wp_cron >/dev/null 2>&1|
|Run||Select Cron Style from the drop down and then enter * * * * *|
|Description||Memorable name for the cron job, specific to your domain.|
|Notify||It’s always a good idea to select the Errors Only option so you’re made aware of any issues in running the cron job|
Click OK and make sure it saves correctly. The Plesk Scheduled Task will now appear in the domain’s and server’s lists of scheduled tasks.
So, now you’ve got Plesk setup you need to see if it’s working right? To do so, we can use the awesome Advanced Cron Manager – debug & control plugin. It’s free and on the WordPress Plugin repo so all you need to do is add it to your site from the WordPress admin area.
Upon installation, open the Tools menu and navigate to Cron Manager. You’ll be presented with a list of all the scheduled actions for your site and when they’re going to run.
Now, sit back and relax while we wait for the next action to run. If it moves off the top of the list at the time it’s meant to run…everything is working!
That’s it!!! You have successfully replaced WordPress cron jobs with Plesk cron jobs that trigger WordPress scheduled actions.
Need some help setting things up? We’d be more than happy to help. Just drop us a message via the form below.