[CentOS] cron job schedule problem

Kwan Lowe kwan.lowe at gmail.com
Thu Jan 7 14:43:08 UTC 2010

2010/1/7 mcclnx mcc <mcclnx at yahoo.com.tw>:
> We have CENTOS 5.3 on DELL server.  there has a cron job supposedly should run on 1st and 3rd week on Saturday but it run everyday.  anyone know what wrong?
> 01 08 1-7,15-21 * 6 program.sh

>From "man 5 crontab"
       The time and date fields are:

              field          allowed values
              -----          --------------
              minute         0-59
              hour           0-23
              day of month   1-31
              month          1-12 (or names, see below)
              day of week    0-7 (0 or 7 is Sun, or use names)

       A field may be an asterisk (*), which always stands for "first-last".

       Ranges of numbers are allowed.  Ranges are two numbers separated with a
       hyphen.  The specified range is inclusive.  For example,  8-11  for  an
       "hours" entry specifies execution at hours 8, 9, 10 and 11.

       Lists are allowed.  A list is a set of numbers (or ranges) separated by
       commas.  Examples: "1,2,5,9", "0-4,8-12".

 01 08 1-7,15-21 * 6 program.sh

So you have the first field (minute), which says run if matched on minute 1.
The next field (hour), says run on the 8th hour.
The next field (day of month), says run on 1st through the 7th, and
15th through 21st.
The next field (month), says run every month.
The next field (day of week) says run on the 6th day (Saturday).

And then this is the important piece:
       Note: The day of a command’s execution can be specified by two fields —
       day of month, and day of week.  If  both  fields  are  restricted  (ie,
       aren’t  *),  the command will be run when either field matches the cur-
       rent time.  For example,
       "30 4 1,15 * 5" would cause a command to be run at 4:30 am on  the  1st
       and 15th of each month, plus every Friday.

So your above example will run every day from 1-7, any Saturdays in
between, and 15 through 21.

More information about the CentOS mailing list