How to replace the WordPress Cron with a real Cron job in Plesk for Linux

WordPress has their own pseudo Cron. The file wp-cron.php is triggered when a page is requested by a visitor to the website. This pseudo Cron will sometimes fail so to avoid this we can disable the WordPress Cron and setup a real Linux Cron job in Plesk.

First, you need to tell WordPress to stop running the wp-cron.php. To do this, edit the wp-config.php.
Scroll down and look for

/* That’s all, stop editing! Happy blogging. */

and just above that add the following

define('DISABLE_WP_CRON', true);

Click OK to save the file and exit.
Next, login to Plesk.
Click on Subscriptions > example.com.
Click on Scheduled Tasks from the right hand column.
Click on Add Task
Select Run a PHP script
For the Script path enter httpdocs/wp-cron.php.
Under Run where it says "Daily" click it and from the drop down menu select Cron style.
In the next field enter */5 * * * * to run it every 5 minutes.
Replace */5 with */10 for 10 minute intervals and */15 for fifteen minute intervals.
Add a description, something like example.com wp-cron.php
Choose whether to be notified if there are errors running the script and choose which email address to send the notifications to.
Click OK to save and exit.

For more information on running tasks using the Cron task style you can refer to this website.
https://tecadmin.net/crontab-in-linux-with-20-examples-of-cron-schedule/ Opens in new window

The article below from Plesk illustrates how to add a cron job to run every 1 minute
https://support.plesk.com/hc/en-us/articles/115003372214 Opens in new window

There is also this article in the Plesk documentation which discusses how to add a scheduled task
https://docs.plesk.com/en-US/onyx/administrator-guide/website-management/scheduling-tasks.65207/ Opens in new window

If you find this tutorial has helped you please give a thumbs up. If you find something that needs to be corrected or improved please drop us a line by contacting us here Opens in new window and let us know.

  • WordPress, Cron, Plesk
  • 6 Users Found This Useful
Was this answer helpful?

Related Articles

How to setup a WordPress Multisite on a Plesk server

You can use this guide to install and setup WordPress Multisite. This article is an expansion...

Powered by WHMCompleteSolution