0 0 21 * * Cron Expression

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

**Cron Expression: 0 0 21 * ***

A cron expression is a string consisting of five or six fields separated by spaces, used to schedule tasks in a Linux or Unix-like operating system. In this article, we will breakdown the cron expression 0 0 21 * * and explain what it does.

Fields of a Cron Expression

A cron expression consists of five fields, each representing a different aspect of the schedule:

  • Minute (0-59)
  • Hour (0-23)
  • Day of the month (1-31)
  • Month (1-12)
  • Day of the week (0-6), where 0 = Sunday

**The Expression: 0 0 21 * ***

Now, let's breakdown the expression 0 0 21 * *:

  • Minute: 0 - This means the task will run at the 0th minute of the hour, i.e., at the start of the hour.
  • Hour: 0 - This means the task will run at 21:00 (9:00 PM) every day.
  • Day of the month: 21 - This means the task will run on the 21st day of every month.
  • Month: * - This is a wildcard, meaning the task will run every month (January to December).
  • Day of the week: * - This is a wildcard, meaning the task will run every day of the week (Monday to Sunday).

What Does it Do?

The cron expression 0 0 21 * * will run a task at 21:00 (9:00 PM) every day, regardless of the day of the month or day of the week.

For example, if you have a script that needs to run daily at 9:00 PM, you would use this cron expression to schedule it. The script will run every day at 9:00 PM, without any exceptions.

Conclusion

In conclusion, the cron expression 0 0 21 * * is a simple and straightforward way to schedule a task to run daily at 9:00 PM. By understanding the different fields of a cron expression, you can create custom schedules to suit your specific needs.

Related Post