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

Re: cron: nth <weekday> of month?



On Fri, Apr 27, 2001 at 01:20:00AM -0400, Dan Christensen wrote:
> Does anyone have any clever solutions to the following problem of a
> similar nature:  I want to run a job at 28 day intervals, i.e. on
> every fourth Sunday.

Not terribly clever, but just end your script with

echo '/path/to/script' | at now + 28 days

and then run it manually (or from a manually-scheduled at job) on a Sunday.
It will repeat itself every 28 days.

Unfortunately, cron is not suited to scheduling tasks on criteria other than
what the date itself looks like.  Something like this requires knowledge of
when the job last ran and cron doesn't know that.

You could also do it based off the week of the year, obtained from date %U,
%V, %w, or %W, but that could result in non-28-day intervals at the end of
the year.

-- 
That's not gibberish...  It's Linux. - Byers, The Lone Gunmen
Geek Code 3.1:  GCS d? s+: a- C++ UL++$ P++>+++ L+++>++++ E- W--(++) N+ o+
!K w---$ O M- V? PS+ PE Y+ PGP t 5++ X+ R++ tv b+ DI++++ D G e* h+ r y+



Reply to: