Oracle
Crontab Entries
Oracle Tips by Burleson Consulting
Advanced Oracle Utilities: The Definitive Reference by
Rampant TechPress is written by four of the top Oracle
database experts (Bert Scalzo, Donald
Burleson, and Steve Callan). The following is an excerpt
from the book.
The most important thing to remember is that a
crontab entry will execute every time all of its
conditions are met.
To take the last entry as an example, any
time it is 00 minutes past the hour of 12 on any
day of the month and any month of the year and
the day of the week is between Monday and Friday
inclusive (1-5), this crontab will be executed.
Wildcards will be used in most crontab entries,
but care must be taken in using them.
For instance, if a * was mistakenly
placed in the minute position of the last
crontab example above, the script for every
minute of the 12:00 hour would end up running
instead of just once at the beginning of the
hour.
Someone should not need that many
reminders to go to lunch!
As mentioned previously, the day-of-week field
accepts either zero or seven as a value for
Sunday.
Any of the time/date fields can also
contain an asterisk (*) indicating the entire
range of values.
Additionally, month and day-of-week
fields can contain name values, consisting of
the first three letters of the month or day, as
indicated in Table 11.3 below.
Field
|
Valid Entries (case insensitive)
|
Days of the week
|
sun, mon, tue, wed, thu, fri, sat
SUN, MON, TUE, WED, THU, FRI,
SAT
|
Months of year
|
jan, feb, mar, apr, may, jun, jul,
aug, sep, oct, nov, dec
JAN, FEB,
MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC
|
Table 11.3:
Day-of-week/Month-of-year Field Values
When numbers are used, the user can specify a
range of values separated by a hyphen or a list
of values separated by commas.
In other words, specifying 2-5 in the
hour field means 2AM, 3AM, 4AM and 5AM, while
specifying 2,5 means only 2AM and 5AM.
How to specify the date and time in the crontab
has been covered in detail, but what about the
command?
Well, most folks will write shell scripts
to execute with their crontab entries but one
can actually just execute a native Linux command
from the crontab.
Either way, make sure to put the fully
qualified path to the command in the crontab.
Crontab options and commands are also
covered in Chapter 4 under the subject of
server-side utilities.
If the command or script that is called in the
crontab typically sends output to the screen, it
is best to redirect that output to a log file
with the >> symbol so it can be checked later.
Be careful with this as the log files may
get rather large over time!
|
|
|