47

I have seen a crontab record in system.

0-55/5 * * * *   root  <command>

I read the crontab -e example files and I know the first position stands for minute. But I cannot figure out the meaning of / (slash) there. Could anyone explain the meaning to me?

Mat
  • 52,586
steveyang
  • 1,121
  • 3
    man 5 crontab has explanations too. – Mat Feb 18 '12 at 08:29
  • @jw013 thanks for correcting! @Mat Thanks. Buy the way, how to go to next page with man? I read through man crontab and through it was the end. – steveyang Feb 18 '12 at 08:35
  • 1
    @yangchenyun, it's not the next page. It's another section. man crontab brings up the first entry for crontab, which is for the crontab command in section 1. Towards the end of that manpage, it says SEE ALSO crontab(5). That tells you that you can use man 5 crontab to read the crontab entry in section 5, which describes the format of the crontab file. – cjm Feb 18 '12 at 09:17
  • @cjm Thanks for this information. I was always wondering about those (3) thing in the SEE ALSO section! – steveyang Feb 18 '12 at 13:21

2 Answers2

46

The forward slash is used in conjunction with ranges to specify step values.

0-55/5 * * * * means your command will be executed every five minutes (0, 5, 10, 15, ..., 55).

0-55/5 is the same as */5.

Will
  • 2,754
uloBasEI
  • 3,047
  • 1
    what about */31 on the minute field. Does it means the scrip will on on 0 and 31 or 1 and 31? – Daniel Shen May 25 '15 at 04:24
  • 1
    @DanielShen It would run on 0 and 31 on every hour. – Ville Apr 14 '16 at 05:41
  • 2
    why do /5 * * * instead of 5 * * * * ? Are they not the same? – Andrew Sep 14 '17 at 20:16
  • 11
    @Andrew 5 * * * * will run at five minutes after the top of the hour, every hour (i.e., once an hour). */5 * * * * will run every five minutes (i.e., twelve times an hour) – purplexa Sep 19 '17 at 17:11
  • I would like to suggest to @purplexa to propose that additional clarification in the answer. I tried but unfortunately the edit queue is full now – Valerio Bozz Jun 19 '23 at 07:47
1

I've found an useful info from the official documentation:

Step values can be used in conjunction with ranges. Following a range with /<number> specifies skips of the number's value through the range. For example, 0-23/2 can be used in the hours field to specify command execution every other hour (the alternative in the V7 standard is 0,2,4,6,8,10,12,14,16,18,20,22). Steps are also permitted after an asterisk, so if you want to say every two hours, just use */2.

man 5 crontab - 4th Berkeley Distribution - 19 April 2010

In short, all of these are valid syntax:

0-55/5 * * * *
\       \ \ \ \- every day of week
 \       \ \ \-- every month
  \       \ \--- every day of month
   \       \---- every hours
    \----------- from minute 0 to 55, using a step of 5 minutes

That means minute 0, 5, 10, 15, ..., 45 and 55 included.