One day ago I was telling you how to speed up WordPress with Docker and Cron. Today I’m going to show you how to use Cron for WordPress if you have installed the non Docker version of WordPress like the original WordPress Synology package or the original WordPress downloaded from wordpress.org on your Synology NAS. WordPress is a powerful Content Management System that has its own built-in Cron system known as WP Cron. WP Cron is a task scheduler for WordPress that allows you to schedule various tasks such as publishing scheduled posts, running database maintenance, and sending scheduled emails. However, the integrated WP Cron has a few limitations. One of the major limitations is that it relies on website traffic to run scheduled tasks.
This means that if your website doesnât receive any traffic, then the scheduled tasks wonât run. In addition, if you have a website that generates high-traffic, the WP Cron integrated in WordPress can cause some performance issues as it can lead to an increase in server load. To overcome these limitations, you can use the server (Synology) side Cron instead of the WP Cron. In this tutorial, I will guide you on how to use the server Cron in WordPress instead of the built-in WP Cron.
STEP 1
Please Support My work by Making a Donation.
STEP 2
Install WordPress using my step by step Docker guide. If you already have WordPress installed on your Synology NAS, skip this STEP.
STEP 3
Install Text Editor via Synology âPackage Centerâ. (Mandatory STEP.) If you already have Text Editor installed on your Synology NAS, skip this STEP.
STEP 4
Make sure you have installed Synology Text Editor as per the instructions at STEP 3. Double click on the wp-config.php file in your wordpress folder under the web folder to open it. Follow the instructions in the image below.
STEP 5
Under the Sets up WordPress vars and included files line, copy and paste this supplementary line. Click X to save the file. Follow the instructions in the image below.
define('DISABLE_WP_CRON', true);
STEP 6
Go to Control Panel / Task Scheduler / Create / Scheduled Task / User-defined script. Follow the instructions in the image below.
STEP 7
Once you click on User-defined script a new window will open. Follow the instructions below:
- General: In the Task field type in âWordPress CRONâ. Check the âEnabledâ option. Select root User.
- Schedule: Select Run on the following days then select âDailyâ. Check Continue running within the same day then select Repeat Every 15 minutes.
- Task Settings: Type in your own email then Check “Send run details by email” and âSend run details only when the script terminates abnormallyâ. Copy paste the code below in the Run command area. After that, click OK.
/bin/su -s /bin/sh -c "/usr/local/bin/php82 -f /volume1/web/wp_mariushosting/wp-cron.php" http
Note: Before you paste the code in the Run command area below, remember to change php82 with the php version that you use for your WordPress instance. php80 for PHP 8.0 php74 for PHP 7.4 or php82 for PHP 8.2.
Note: Before you paste the code in the Run command area below, remember to change the wp_mariushosting folder name with your own wordpress folder name.
STEP 8
After you click OK on STEP 7 a new warning pop up window will open. Click OK.
After you click OK, type in your DSM Password then click Submit. Follow the instructions in the image below.
STEP 9
After you click Submit at STEP 8, select your âWordPress CRONâ Task then click the âRunâ tab. You will be asked to run WordPress CRON â click OK. Follow the instructions in the image below.
Note: That’s it! Using a server Cron job instead of the WP Cron is a great way to ensure that your scheduled tasks run reliably and efficiently, regardless of website traffic. Setting up a server side Cron job is a straightforward process that can help improve the performance and reliability of your website hosted on your Synology NAS device.
This post was updated on Tuesday / August 15th, 2023 at 5:16 PM