[Solved]: Cron, > 1 month but < 2 months
On Fri, 09 Mar 2012 12:37:19 +0100, Florian Ernst 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.
Comparing to other posted answers, this is simply the easy way to
schedule.
I'll go with every 6 weeks (~45 days), or heck, go with every 7 weeks
because the script won't care if a year can be devided up in 7 weeks
nicely.
0 12 * * 1 [ $(expr $(/bin/date +\%s) / 60 / 60 / 24 / 7 \% 7) -eq 3
>> > ] && myscript || /bin/true
Thanks Florian.
--
Tong (remove underscore(s) to reply)
http://xpt.sourceforge.net/techdocs/
http://xpt.sourceforge.net/tools/
Reply to: