Skip site navigation (1)Skip section navigation (2)
Date:      01 Mar 2005 14:10:52 -0500
From:      Lowell Gilbert <freebsd-questions-local@be-well.ilk.org>
To:        "Eugene M. Minkovskii" <emin@mccme.ru>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: crontab synatx
Message-ID:  <44zmxn41xf.fsf@be-well.ilk.org>
In-Reply-To: <20050301072235.GA24150@mccme.ru>
References:  <20050301072235.GA24150@mccme.ru>

next in thread | previous in thread | raw e-mail | index | archive | help
"Eugene M. Minkovskii" <emin@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/



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?44zmxn41xf.fsf>