0 0 21 * * Cron Expression Meaning

3 min read Jul 03, 2024
0 0 21 * * Cron Expression Meaning

Cron Expression: 0 0 21 * * Meaning

Cron expressions are used to schedule tasks to run at specific times or intervals. In this article, we will break down the meaning of the cron expression 0 0 21 * *.

Cron Expression Structure

A cron expression consists of five or six fields, separated by spaces. The five fields are:

  1. Minute (0-59)
  2. Hour (0-23)
  3. Day of the month (1-31)
  4. Month (1-12)
  5. Day of the week (0-6), where 0 = Sunday

The sixth field, which is optional, is the year (1970-2099).

**Breaking Down the Expression: 0 0 21 * * **

Let's break down the cron expression 0 0 21 * *:

  • Minute: 0 - The task will run at minute 0, which means the task will start at the beginning of the hour.
  • Hour: 0 - The task will run at hour 21, which is equivalent to 9:00 PM.
  • Day of the month: * - The asterisk is a wildcard character that means "any" value. Therefore, the task will run every day of the month.
  • Month: * - Again, the asterisk is a wildcard character, meaning the task will run every month.
  • Day of the week: * - The final asterisk indicates that the task will run every day of the week.

Meaning of the Cron Expression

In summary, the cron expression 0 0 21 * * means:

"The task will run every day at 9:00 PM (21:00) sharp."

This expression is useful for scheduling tasks that need to run daily at a specific time, such as daily backups or report generation.

I hope this helps! Let me know if you have any questions.