0 0 */3 * * Cron Expression

4 min read Jul 03, 2024
0 0 */3 * * Cron Expression

**Cron Expression: 0 0 */3 * *

Introduction

A cron expression is a string consisting of five or six fields separated by spaces, used to schedule tasks to run at specific times or intervals. In this article, we will delve into the meaning and usage of the cron expression 0 0 */3 * *.

Breaking Down the Expression

Let's break down the cron expression 0 0 */3 * * into its individual components:

Minute Field: 0

The first field specifies the minute at which the task should run. In this case, the value 0 indicates that the task should run at the beginning of every hour, i.e., at minute 0.

Hour Field: 0

The second field specifies the hour at which the task should run. The value 0 indicates that the task should run at midnight (12:00 AM).

Day Field: */3

The third field specifies the day of the month on which the task should run. The */3 notation indicates that the task should run every 3 days, starting from day 1 of the month.

Month Field: *

The fourth field specifies the month in which the task should run. The asterisk (*) indicates that the task should run in every month.

Day of the Week Field: *

The fifth field specifies the day of the week on which the task should run. The asterisk (*) indicates that the task should run on every day of the week (i.e., Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, and Sunday).

Example

If we put it all together, the cron expression 0 0 */3 * * would cause a task to run:

  • At midnight (12:00 AM)
  • Every 3 days starting from day 1 of the month
  • In every month
  • On every day of the week

For example, if today is January 1st, the task would run on:

  • January 1st, 4th, 7th, 10th, 13th, 16th, 19th, 22nd, 25th, and 28th
  • February 1st, 4th, 7th, 10th, 13th, 16th, 19th, 22nd, 25th, and 28th
  • And so on...

Conclusion

In conclusion, the cron expression 0 0 */3 * * is a powerful and flexible way to schedule tasks to run at specific intervals. By understanding the individual components of the expression, you can create customized schedules to suit your needs.

Featured Posts