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?

4
  • 3
    man 5 crontab has explanations too. Commented Feb 18, 2012 at 8: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. Commented Feb 18, 2012 at 8: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. Commented Feb 18, 2012 at 9:17
  • @cjm Thanks for this information. I was always wondering about those (3) thing in the SEE ALSO section! Commented Feb 18, 2012 at 13:21

2 Answers 2

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.

6
  • 1
    what about */31 on the minute field. Does it means the scrip will on on 0 and 31 or 1 and 31? Commented May 25, 2015 at 4:24
  • 1
    @DanielShen It would run on 0 and 31 on every hour. Commented Apr 14, 2016 at 5:41
  • 2
    why do */5 * * * * instead of 5 * * * * ? Are they not the same? Commented Sep 14, 2017 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) Commented Sep 19, 2017 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 Commented Jun 19, 2023 at 7: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.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.