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

Re: [OT] Cron and day of the week



On Wednesday, 25.03.2009 at 16:34 +0000, Avi Greenbury wrote:

> T o n g wrote:
>> I know we can put day of the week info as cron schedules, but how can I 
>> define:
>>
>> - first Monday of the month
>> - second Monday of the month
>> - last Monday of the month
>
> The first Monday of the month will be the only Monday within the first  
> seven days of the month.
>
> 0 0 1-7 * 1 command
>
> would schedule command to run at midnight on any Monday that is between  
> the first and seventh day of the month inclusive, which should always be  
> the first Monday of that month.

I don't think that'll work as the original poster expects.

If you specify both the day numbers *and* the day of the week in the
crontab, the command will run when *either* matches; so your suggestion
will run:

- each day on 1st to 7th of the month;

and

- each Monday (for the whole month).

i.e. for March 2009, it will run on 1st through 7th inclusive and also
on 9th, 16th, 23rd and 30th.

Dave.

-- 
Dave Ewart
davee@ceu.ox.ac.uk
Computing Manager, Cancer Epidemiology Unit
University of Oxford / Cancer Research UK
PGP: CC70 1883 BD92 E665 B840 118B 6E94 2CFD 694D E370
Get key from http://www.ceu.ox.ac.uk/~davee/davee-ceu-ox-ac-uk.asc
N 51.7516, W 1.2152

Attachment: signature.asc
Description: Digital signature


Reply to: