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

Re: cron: nth <weekday> of month?



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

Rob

-- 
One can search the brain with a microscope and not find the
mind, and can search the stars with a telescope and not find God.
		-- J. Gustav White



Reply to: