Tip: Start typing to get instant search results.
How to replace WordPress WP-Cron with a real Cron Job
WP-Cron is a pseudo-cron scheduler that WordPress uses to run scheduled tasks, such as publishing posts, checking for updates and running tasks for WordPress plugins. WP-Cron is triggered every time someone visits the website and loads one of its pages. This can cause problems on a low-traffic website, where scheduled tasks may run late, and also on a high-traffic website, where scheduled tasks will run constantly because of the many frequent visits it receives.
To avoid these problems, we’ll replace the WordPress pseudo-cron (WP-Cron) with a real task scheduler, that is, a real cron job. This way, the server takes over scheduling the tasks at set intervals, regardless of how much traffic the website receives.
In short, below we’ll see how to change the way WordPress scheduled tasks are triggered, so that they run at specific times, regardless of the number and frequency of visits the website receives.
The process is different for a dedicated server than for a shared hosting server with the DirectAdmin panel.
Replacing WP-Cron on a dedicated server without a panel
You will need the login details for the server (SSH) and your 2FA one-time code device. If this is your first time connecting, first follow the article First SSH connection for dedicated servers.
- We connect via SSH to the server that hosts WordPress:
ssh user@myserver.trustservers.grWe replace user and myserver.trustservers.gr with the details from the “Welcome Kit”. We’ll be asked for the password and the TrustServersPIN from the 2FA one-time code device.
- We check that WP-CLI is available and that it recognizes the WordPress installation:
cd /home/user/public_html && wp cron event listWe replace
userwith our account’s username, the same one we used for the SSH connection. If WordPress is in a subfolder, we replace/home/user/public_htmlwith the path of the folder that contains our WordPresswp-config.phpfile.
If the list of scheduled tasks appears, the path is correct and WP-CLI is available, so we can proceed. - We open the crontab for editing, using the nano editor:
EDITOR=nano crontab -eUsing the arrow keys, we move to the end of the file and add the following entry on a new line.
*/5 * * * * cd /home/user/public_html && wp cron event run --due-nowWe replace
/home/user/public_htmlwith the same path we used in the previous step. If the file already contains an entry that calls the same wp-cron.php (e.g. with wget or curl), we replace it with the one above so that the tasks don’t run twice.To return to the terminal, we press Ctrl + X, then Y to save the changes and Enter to confirm the file name.
We can check that the entry was saved with the command:
crontab -lThis way, the server makes sure that scheduled tasks are triggered every 5 minutes. We can adjust the frequency to suit the website’s needs and our server’s resources. For example, to trigger them every 2 minutes instead of 5, we simply replace */5 with */2 in the command above.
- Finally, we open our WordPress wp-config.php file and, before the line that looks like
/* That's all, stop editing! Happy publishing. */, we add:define( 'DISABLE_WP_CRON', true );If this setting already exists in the file with the value false, we simply change its value to
trueand save the file. This way, visits will no longer trigger WP-Cron automatically, since the server has now taken over this process.
The process is complete. We can change the execution frequency at any time simply by editing the line we added to the crontab in step 3.
Replacing WP-Cron on a server with the DirectAdmin panel
You will need the login details for your DirectAdmin account.
- We access DirectAdmin by typing our domain as domainname.tld:2222 and log in with our username and password.
- We select Cron Jobs from the Advanced Features section and then click the CREATE CRON JOB button.
- We add the following cron job as shown in the image, so that the server triggers the scheduled tasks every 5 minutes.
*/5 * * * * cd /home/user/public_html && wp cron event run --due-now - Finally, we open our WordPress wp-config.php file through the DirectAdmin File Manager and, before the line that looks like
/* That's all, stop editing! Happy publishing. */, we add:define( 'DISABLE_WP_CRON', true );If this setting already exists in the file with the value false, we simply change its value to
trueand save the file. This way, visits will no longer trigger WP-Cron automatically, since the server has now taken over this process.
The process is complete. We can change the execution frequency at any time simply by editing the cron job in the DirectAdmin panel.


