How to set up a WordPress cron job using the Command line

October 13, 2023 / WordPress

In this article, we will explain how to set up a WordPress cron job using the command line.

Follow these steps to set up a WordPress cron job using the command line:

  1. Log into your account using SSH.
  2. Type the following command
    crontab -e
  3. Please type “O” to enter edit mode and begin a new line of text.
  4. Please type the following line, replacing “username” with your own WHUK account username:
  5. In the “Command” text box, enter the following line:
    */30 * * * * cd ${HOME}/public_html; /usr/local/bin/php -q wp-cron.php

    Note: “This line configures the cron job to execute every 30 minutes. If you’re using an unmanaged platform, you have the flexibility to schedule cron jobs as frequently as needed. However, on shared and reseller accounts, cron jobs can be scheduled at a maximum interval of every 15 minutes. A 30-minute interval for the WordPress cron job is typically more than adequate.

    Please note that this line assumes you’ve installed WordPress in the document root (public_html) directory. If you’ve installed WordPress in a different directory, be sure to adjust the ‘cd’ command to change to that specific directory instead.”

  6. Press the “Esc” key, type “:wq,” and then press “Enter” to save the changes. The updated cron job settings will become active immediately.

In this way, you can set up a WordPress cron job using the command line.

Setting up a WordPress cron job using the command line increases the overall performance of your website and can streamline and automate various tasks.
If you need to disable WordPress cron jobs, you can follow our guide to Disable Cron Job in WordPress.

Dominos Search