 |
|
Oracle cron crontab examples
Oracle Database Tips by Donald Burleson |
With the exception of the environment setup, each
line in the crontab file represents a scheduled task by using
the following syntax:
field allowed values
----- --------------
minute 0-59
hour 0-23
day of month 1-31
month 1-12
day of week 0-7 (both 0 and
7 are Sunday)
user Valid OS user
command Valid command
or script.
The date fields can contain a number of patterns
to form complex schedules, as shown below.
* -
All available values or "first-last".
3-4 - A
single range representing each possible from the
start to the end of the
range inclusive.
1,2,5,6 - A
specific list of values.
1-3,5-8 - A
specific list of ranges.
0-23/2 -
Every other value in the specified range.
In Red Hat Linux, the month and day names can be
used to specify these fields. The following examples show a
selection of possible schedules:
30 * * * * root echo "Runs at
30 minutes past the hour."
45 6 * * * root echo "Runs at
6:45 am every day."
45 18 * * * root echo "Runs at
6:45 pm every day."
00 1 * * 0 root echo "Runs at
1:00 am every Sunday."
00 1 * * 7 root echo "Runs at
1:00 am every Sunday."
00 1 * * Sun root echo "Runs
at 1:00 am every Sunday."
30 8 1 * * root echo "Runs at
8:30 am on the first day of every month."
00 0-23/2 02 07 * root echo
"Runs every other hour on the 2nd of July."
By default, the output from a job is
electronically mailed to the owner of the job or the user specified
by the mailto variable. If this is unacceptable, the output
can be redirected in a number of ways including:
# Mail the output of the job
to another user.
command | mail -s "Subject:
Output of job" user
# Standard output redirected
to a file.
command >> file.log
# Standard output and standard
error redirected to a file.
command >> logfile 2>&1
# Throw all the output away.
command >> /dev/null 2>&1
For more details, see the book
Oracle Job Scheduling:
Creating robust task
management with dbms_job and Oracle 10g dbms_scheduler, by
Dr. Timothy Hall
 |
If you like Oracle tuning, see the book "Oracle
Tuning: The Definitive Reference".
You can buy it direct from the publisher for 30%-off and get
instant access to the code depot of Oracle tuning scripts. |
|