This KB article will provide you with information about Cron Jobs and its usage. Moreover, you will also learn what WP-Cron and WordPress CLI are and how to list WP-Cron jobs/events using WordPress CLI.

What are Cron Jobs?

Cron is a standard Unix/Linux-like utility and one of the most useful features that schedule a script or command to be executed automatically at a specified date and time. Scheduled commands, scripts, and tasks are called Cron Jobs. This feature was introduced to automate the process of repetitive tasks.

Please be advised that it is highly recommended for you to be acquainted with the Cron Jobs and their work to use this feature effectively. Also, knowing Linux and its commands will be a bonus.

The typical format of the Cron Job command is as follows:

Minute(0-59) Hour(0-24) Day_of_month(1-31) Month(1-12) Day_of_week(0-6) Command_to_execute

Common Applications

Common applications of Cron are as follows:

  • Deleting temporary files which are no longer needed, e.g., log files

  • Making scheduled backups

  • Monitoring disk space or other resources

  • Modifying database or files

  • Running system maintenance tasks.

What is WP-Cron?

WP-Cron is a Cron Jobs management tool of WordPress which handles the time-based tasks of WordPress application such as publishing the scheduled posts, checking for plugin or themes updates, etc.

Tip

A frequently triggered resource-intensive cron could cause your server to fall short of resources, so you may need to check WP-Cron hooks often to see if they are jammed.

WP-CLI is pre-installed on all the servers deployed on Cloudways, and the steps below will demonstrate how you can operate WP-CLI and update the password.

What is WordPress CLI?

WP-CLI is a command-line interface for WordPress, and it is a set of command-line tools for managing WordPress installations on a server. It allows the WordPress admin users to carry out different administrative tasks without actually using a web browser. This management through the command-line interface allows the users to manage their WordPress websites by executing a set of defined commands. The scope of the tasks mainly includes upgrades, taking database backups, publishing new posts, and much more.

How to List WP-Cron Events

Below are a few simple steps to help you view scheduled WP-Cron Events.

Step# 1

First of all, you need to connect to your server remotely via SSH so you can use WP-CLI.

If you would like to know what is SSH and why it is used, then Click Here to find out. In this example, we are using Master Credentials to access the server remotely.

You can connect to your server via SSH in two ways, so choose your preferred option from the below options. You can also click on the hyperlink text of bullet points to learn about connecting remotely to the server.

In this example, we have used an SSH client named PuTTY. You will see a similar window after successful connection as shown below:

Step# 2

Now, you need to go to that specific directory where your webroot is located. In other words, where your wp-config.php file is located else, WP-CLI will not work. By default, it is in the public_html directory and we will also follow the default path to operate WP-CLI in this example. Enter a command mentioned below to go into the public_html folder.

Important

Angle brackets are included to indicate the positions of your inputs so make sure to remove the angle brackets. Your application name is the same as your Database name (DB name). Click Here to find out where your application name is located.

You will see a similar window after running the above command successfully.

Step# 3

You may start using WP-CLI once you are in the public_html directory. Typing the command below will list all the WP-Cron events.

wp cron event list

Tips

You can also add more parameters to list cron events based on your needs.

For instance, if you would like to list the scheduled WP-Cron events in JSON format, including only two fields (columns) only, then you may type this command.

wp cron event list --fields=hook,recurrence --format=json

Also, see some useful options (parameters) and their functions below:

Other Parameters

Command

Description

--fields=<fields>

Limit the output to specific object fields.

--<field>=<value>

Filter by one or more fields.

--field=<field>

Prints the value of a single field for each event.

--format=<format>

Render output in a particular format.

  • default: table

Options:

  • table

  • csv

  • ids

  • json

  • count

  • yaml

Source: WordPress CLI

Click Here to learn about disabling the WP-Cron for blistering performance.

That’s it! We hope this article was helpful. If you need any help, then feel free to search your query on Cloudways Support Center or contact us via chat (Need a Hand > Send us a Message). Alternatively, you can also create a support ticket.

Did this answer your question?