In this article, we will explain how to set up a WordPress cron job using the command line.
Let us follow the simple steps:
- Log into your account using SSH.
- Enter the following command-
crontab –e
- Enter “O” to go to the edit mode and start a new line of text.
- Now, enter the below-outlined by replacing “username” with your account username.
- In the “Command” text box, enter the following line-
*/30 * * * * cd ${HOME}/public_html; /usr/local/bin/php -q wp-cron.php
Important note- This line sets the cron job to run every 30 minutes. On unmanaged platforms, you can schedule cron jobs as often as needed. However, on shared and reseller accounts, the maximum frequency is every 15 minutes. A 30-minute interval for the WordPress cron job is generally sufficient.Keep in mind that this example assumes WordPress is installed in the document root (public_html) directory. If your WordPress installation is in a different directory, update the ‘cd’ command to reflect the correct path.
- Press the “Esc” key, type “:wp”, and then press, “Enter” to save the changes. The updated cron job settings will take effect immediately.
By setting up a WordPress cron job using the command line, you can improve your website’s performance and automate various tasks efficiently.
Hope you liked our article!