What does * * * * * (five asterisks) in a cron file mean? [duplicate]
Solution 1:
Every minute of every day of every week of every month, that command runs.
man 5 crontab
has the documentation of this. If you just type man crontab
, you get the documentation for the crontab command. What you want is section 5 of the manual pages which covers system configuration files including the /etc/crontab
file. For future reference, the sections are described in man man
:
1 Executable programs or shell commands
2 System calls (functions provided by the kernel)
3 Library calls (functions within program libraries)
4 Special files (usually found in /dev)
5 File formats and conventions eg /etc/passwd
6 Games
7 Miscellaneous (including macro packages and conven‐
tions), e.g. man(7), groff(7)
8 System administration commands (usually only for root)
9 Kernel routines [Non standard]
Solution 2:
*
= always. It is a wildcard for every part of the cron schedule expression.
So * * * * *
means every minute
of every hour
of every day
of every month
and every day
of the week
.
* * * * * command to execute
┬ ┬ ┬ ┬ ┬
│ │ │ │ │
│ │ │ │ │
│ │ │ │ └───── day of week (0 - 7) (0 to 6 are Sunday to Saturday, or use names; 7 is Sunday, the same as 0)
│ │ │ └────────── month (1 - 12)
│ │ └─────────────── day of month (1 - 31)
│ └──────────────────── hour (0 - 23)
└───────────────────────── min (0 - 59)
The nice drawing above is provided by wikipedia
An other example:
0 * * * *
-this means the cron will run always when the minutes are 0
(so hourly)0 1 * * *
- this means the cron will run always at 1 o'clock.* 1 * * *
- this means the cron will run each minute when the hour is 1. So 1:00
, 1:01
, ...1:59
.
Solution 3:
First star = Minutes: 0-59
Second star = Hours: 0-23
Third star = Day of Month: 0 - 31
Fourth star = Month: 0 - 12
Fifth star = Day of Week: 0 - 6 (0 means sunday)
Say you want to run something every 1st of every month.
0 0 1 * * something.sh