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

Re: cron: nth <weekday> of month?



on Thu, Apr 26, 2001 at 07:23:51AM -0400, Rob Mahurin (robm@mad.scientist.com) wrote:
> On Wed, Apr 25, 2001 at 03:58:28AM -0700, Karsten M. Self wrote:
> > I've got a job I'd like to run once a month, on a set day of the week,
> > say, the first Sunday of the month.  Suggestions as to how to do this
> > with cron?
> > 
> > My understanding is that I can specify day of month, or weekday, but if
> > both are specified the condition is treated as an OR (if first week of
> > month OR Sunday, then do...).  
> > 
> > E.g.:  
> > 
> >     48 2 1 * 7 do-stuff
> > 
> > ...would run on the first of the month, and each Sunday.
> 
> Yup, that's how I read it, too.
> 
> > I could set a job to run either each Sunday, or each of the first seven
> > days of the month, and test the appropriate other condition.
> 
> This is the solution which seems the prettiest to me; something like
> 
>       0 0 1-7 * * [ "$(date +%a)" == "Sun" ] && command -args

Nice.

-- 
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: pgpS9l6rbfrQH.pgp
Description: PGP signature


Reply to: