Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Mailing Lists -> Oracle-L -> Re: Unix - scheduling - I know this, it's a UNIX system
I knew about the start date/offset thingy, but hey, ya gotta leave him something to figure out!!!!
As for the end of year, yeah, you're right. Every year is a problem. Since this is an Oracle news list we could just call Oracle from our shell script and ask for the daze since some constant date and today, do the mod 28 math, and if it's zero, confinue to run the script, otherwise end.
I was just trying to show an inventive way to use cron.
Have a good 4th all.
lembark_at_wrkhors.c om To: Multiple recipients of list ORACLE-L <ORACLE-L_at_fatcity.com> Sent by: cc: root_at_fatcity.com Subject: Re: Unix - scheduling - I know this, it's a UNIX system 07/03/02 03:39 PM Please respond to ORACLE-L
>
> 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). -- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: INET: Brian_P_MacLean_at_eFunds.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 - 19:43:21 CDT