crontab synatx
Lowell Gilbert
freebsd-questions-local at be-well.ilk.org
Tue Mar 1 19:10:53 GMT 2005
"Eugene M. Minkovskii" <emin at mccme.ru> writes:
> I put in my crontab following string:
>
> # min hour mday month wday command
> 0 7 */3 * * echo "Hello world"
>
> So, I hope, this command will be workind every third day:
> 3,6,9,12 etc, because at man crontab we read:
>
> <man 5 crontab>
> 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'').
> </man 5 crontab>
>
> But, my command worked at 28 feb, and 1 march.
The way the "/3" syntax works is that it specifies a "skip" in the
values. It doesn't affect what the *first* value is, so for day of
month, the first value is 1. Then it will skip 3, and will execute
again on the 4th.
I haven't tested this, but I think you could get what you want by
saying "3-31/3" for the mday value.
> Other case I type
>
> # min hour mday month wday command
> 0 7 */14 * * echo "Hello world"
>
> And this is work at 15 febr. Is it bug or feature?
As in the previous example, I think this behavior is exactly what the
documentation describes. If you want the 14th and the 28th of every
month, just put "14,28" in that field of the crontabl
> Is it bug or feature? Perhaps
> crontab count day of month from zero?
No, it counts from one, as everyone would expect. This is required
behavior according to POSIX.
> If so, when should work
> command if I type directly number of day:
>
> # min hour mday month wday command
> 0 7 14 * * echo "Hello world"
That will execute at 7:00 AM on the 14th of every month.
> And how will be counted months?
January is 1, December is 12.
--
Lowell Gilbert, embedded/networking software engineer, Boston area
http://be-well.ilk.org/~lowell/
More information about the freebsd-questions
mailing list