Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> Re: Unix - scheduling - I know this, it's a UNIX system

Re: Unix - scheduling - I know this, it's a UNIX system

From: <lembark_at_wrkhors.com>
Date: Wed, 03 Jul 2002 14:39:07 -0800
Message-ID: <F001.0048F82F.20020703143907@fatcity.com>

>
> This will run the job every 28 daze at 1am. If that's not exactly the
> definition of every 4th week let me know and I'll work something out. Also
> note that you will have an anomaly at the end of leap years.
>
>
> 0 1 * * * /usr/bin/ksh -c '[ $(($(date '+\%j') \% 28)) -eq 0 ] &&
> /path/to/my/job/the_job'

       %j day of year (001..366)

Two problems are not adjusting the initial start date (simple enough, adding a constant) and 365 % 28 != 0. The last will give you an extended period once per year. The only reliable way to handle this requries gnu date, which has %s == system time in GMT:     

    [ $(( ($(date +%s) + $INITIAL_DATE_OFFSET) % 2419200 )) -eq 0 ] && /blah;

Is a bit grimy but works. The wallclock time may shift slightly during the DST correction but the basic interval works.

The one-second resolution can cause problems if crond doesn't run exactly on the minute; this can be corrected by taking the integer portion after dividing by 60 and comparing that.

At which point it's better to give up on cron entirely and use at, which does all of this mess for you and handles cron outages also (which the above doesn't).

--
Steven Lembark                              2930 W. Palmer
Workhorse Computing                      Chicago, IL 60647
                                           +1 800 762 1582
-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: 
  INET: lembark_at_wrkhors.com

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).
Received on Wed Jul 03 2002 - 17:39:07 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US