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

Re: Cron, > 1 month but < 2 months



On Fri, Mar 09, 2012 at 12:08:38PM +0100, Jochen Spieker wrote:
> Florian Ernst:
> > On Fri, Mar 09, 2012 at 05:09:23AM +0000, T o n g wrote:
> >> Is there any easy way to schedule a job for a duration that is greater 
> >> than one month but shorter than 2 months? Any duration will do, as long 
> >> as it is easy to schedule. 
> > 
> > Easy? Hmmm.
> > 
> > 0 12 * * 1 [ $(expr $(/bin/date +\%s) / 60 / 60 / 24 / 7 \% 8) -eq 3 ] && myscript
> 
> Nice.

Oops, forgot to paste the trailing ... || /bin/true which keeps newer
cron from reporting the job as failed whenever [ ... ] doesn't exit
successfully.

>       Is there any reason why you don't use "date '+%V'" (or %W or %U)?

That'd break with every new year: for instance,
[ $(expr $(/bin/date +\%V) \% 8) -eq 1 ]
would trigger on ISO week 1, 9, ..., 41, 49 and then again in the next
year on ISO week 1, resulting in a shorter interval "between" the years
than desired.

Cheers,
Flo

Attachment: signature.asc
Description: Digital signature


Reply to: