[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: cron: nth <weekday> of month?



on Thu, Apr 26, 2001 at 09:09:25AM -0500, Dave Sherohman (esper@sherohman.org) wrote:
> On Wed, Apr 25, 2001 at 03:32:43PM -0700, Karsten M. Self wrote:
> > Hence, my crontab recipie to execute a job on the first sunday of the
> > month is:
> > 
> >   1 1 1 * * echo 'command -args' | at 1:35 sunday
> <snip>
> > For tasks scheduled for other weeks of the month, you'd select:
> > 
> >   Week	Day
> >   ----	---
> <snip>
> >      5  29
> 
> Note also that for any month that is not a non-leap February, this 5th-week
> rule will happily schedule the command for the first week of the following
> month if there isn't a fifth occurrence of the desired weekday that month.

Interesting.  This might be desirable, it might not.

The solution then would be to specify the line accordingly:


To run on the fifth Sunday in a month, only if it exists:

    0 1 29 1,3-12 * 	echo 'command -args' | at 1:34 sunday

To run on the fifth Sunday in a month, *or* the following
Sunday if it does not:

    0 1 29 *      * 	echo 'command -args' | at 1:34 sunday

The special case of running on the fifth Sunday of February in a leap
year, but only if it exists...I don't have a solution at the moment.


Another missing specification:  does anyone have a good "last weekday of
month" recipie?

Cheers.

-- 
Karsten M. Self <kmself@ix.netcom.com>    http://kmself.home.netcom.com/
 What part of "Gestalt" don't you understand?       There is no K5 cabal
  http://gestalt-system.sourceforge.net/         http://www.kuro5hin.org

Attachment: pgpz7xtXtcjDl.pgp
Description: PGP signature


Reply to: