Cron Job: Understanding the Format
In Linux and Unix-like systems, cron jobs are used to schedule tasks to run at specific times or intervals. The format of a cron job can be confusing at first, but once you understand the syntax, it's quite powerful.
Breaking Down the Format
The format of a cron job is as follows:
minute hour day month day_of_week command
Each of the five fields is separated by a space, and they represent the following:
minute
: The minute of the hour when the command should run (0-59)hour
: The hour of the day when the command should run (0-23)day
: The day of the month when the command should run (1-31)month
: The month of the year when the command should run (1-12)day_of_week
: The day of the week when the command should run (0-6), where 0 = Sundaycommand
: The command to be executed
The 0 0/1 * * *
Format
Now, let's break down the format 0 0/1 * * *
.
0
: The minute of the hour when the command should run. In this case, it's set to 0, which means the command will run at the start of the hour.0/1
: The hour of the day when the command should run. The/
symbol is used to specify a step value. In this case, it means the command will run every 1 hour, starting from 0. This means the command will run at 0:00, 1:00, 2:00, and so on.*
: The day of the month when the command should run. The*
symbol is a wildcard, which means the command will run every day of the month.*
: The month of the year when the command should run. Again, the*
symbol is a wildcard, which means the command will run every month of the year.*
: The day of the week when the command should run. Once more, the*
symbol is a wildcard, which means the command will run every day of the week.
In Summary
The 0 0/1 * * *
format means the command will run every 1 hour, starting from 0:00, every day of the month, every month of the year, and every day of the week.