Oracle Consulting Oracle Training Development

Remote DBA

Remote DBA Plans  

Remote DBA Service

Remote DBA RAC

   
Remote DBA Oracle Home
Remote DBA Oracle Training
Remote DBA SQL Tuning Consulting
Remote DBA Oracle Tuning Consulting
Remote DBA Data Warehouse Consulting
Remote DBA Oracle Project Management
Remote DBA Oracle Security Assessment
Remote DBA Unix Consulting
Burleson Books
Burleson Articles
Burleson Web Courses
Burleson Qualifications
Oracle Links
Remote DBA Oracle Monitoring
Remote DBA Support Benefits
Remote DBA Plans & Prices
Our Automation Strategy
What We Monitor
Oracle Apps Support
Print Our Brochure
Contact Us (e-mail)
Oracle Job Opportunities
Oracle Consulting Prices





   

 

 

 

Remote DBA services

Remote DBA Support

Remote DBA RAC

Remote DBA Reasons

Remote Oracle Tuning

Remote DBA Links

Oracle DBA Support

Oracle DBA Forum

Oracle Disaster

Oracle Training

Oracle Tuning

Oracle Training

 Remote DBA SQL Server

Remote MSSQL Consulting

Oracle DBA Hosting

Oracle License Negotiation

 

 


 

 

 

        
 

 Oracle Crontab Command Line Tips
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.

Cron Environment Variable Settings

Each environment variable line consists of a variable name, an equal sign (=), and a value.  Values that contain spaces need to be enclosed within quotes.  The following are some examples of environment variable settings:

 

color = red

title = ‘My Life in a Nutshell’

 

It is important to remember that variable names are case sensitive and that system variables are usually defined with upper case names, while user defined variables are defined with lower case names.

Crontab Command Line Tips

Each crontab command line is comprised of six positional fields specifying the time, date and shell script or command to be run.  The format of the crontab command line is described in Table 11.2 below:

 

Field

Minute

Hour

Day of Month

Month

Day of Week

Command

Valid values

0-59

0-23

1-31

1-12

0-7

Command path/command

Table 11.2:  Crontab Command Line Format

 

Each of these fields can contain a single number, a range of numbers indicated with a hyphen (such as 2-4), a list of specific values separated by commas (like 2,3,4) or a combination of these designations separated by commas (such as 1,3-5).  Any of these fields may also contain an asterisk (*) indicating every possible value of this field.  This can all get rather confusing, so here are a few examples that are all part of the same crontab file.  It has been broken up so as to explain each entry individually.

 

# Use the Korn Shell for all shell scripts

SHELL=/bin/ksh

 

This sets the default shell for these cron scripts by setting the SHELL environment variable.

 

#**********************************************************

# Run the Weekly file cleanup task at 6:00AM every Monday

# and send any output to a file called cleanup.lst in the

# /tmp directory

#**********************************************************

00 06 * * 1 /home/terry/cleanup.ksh > /tmp/cleanup.lst

 

This entry will run the script cleanup.ksh at 0 minutes past the hour of 6:00 am, every day of the month, every month of the year, but only on Mondays.  This illustrates that for a crontab to execute, all of the conditions specified must be met. So even though it was stated that the designation is every day of the month by making the third field a wildcard, the day also has to meet the final condition that the day is a Monday.

 

#**********************************************************

# Run the Weekly Management Report every Monday at 7:00 AM

# and save a copy of the report in my /home directory

#**********************************************************

00 07 * * 1 /home/terry/weekly_mgmt_rpt.ksh wprd > /home/terry/weekly_mgmt_rpt.lst

 

This entry is very similar but will execute at 7:00 am.  Since the hour is in 24-hour format (midnight is actually represented as 00), then 07 represents 7:00 a.m.  Again, this entry will only be run once a week.

 

#**********************************************************

# Weekly Full Backup - run every Sunday at 1:30AM

#**********************************************************

30 01 * * 0 /home/terry/full_backup.ksh wprd > /tmp/full_backup.lst

 

Here this script is specified to be run at 30 minutes past the hour, the first hour of the day, but only on Sundays.  Remember that in the day of the week column, Sunday can be represented by either 0 or 7.

 

#**********************************************************

# Nightly Incremental Backup - run Monday-Saturday at 1:30AM

#**********************************************************

30 01 * * 1-6 /home/terry/incr_backup.ksh  > /tmp/incr_backup.lst

 

In this crontab entry, it shows the same indication for hour and minute as the last entry, but a range has been specified for the day of the week.  The range 1-6 will cause the incr_backup.ksh to be executed at 1:30 every morning from Monday through Saturday.

 

#**********************************************************

# Low disk space alert ... run every 15 minutes, sending

# alerts to key individuals via e-mail

#**********************************************************

00,15,30,45 * * * * /home/terry/free_space.ksh > /tmp/free_space.lst

 

This entry has minutes separated by a comma indicating that it should be run at each of the indicated times.  Since all the other fields are wildcards (*), the entry will be run on the hour (00), 15 minutes past the hour, 30 minutes past the hour and 45 minutes past the hour.

 

#**********************************************************

# Lunch Time Notification - run Monday-Friday at Noon -

# sends a message to all users indicating it's lunch time

#**********************************************************

00 12 * * 1-5 /home/terry/lunch_time.ksh wprd > /tmp/lunch_time.lst

 

This lunch reminder is set up to run at 12:00 p.m. Monday through Friday only.

     

Remote DBA Service
 

Oracle Tuning Book

 

Advance SQL Tuning Book 

BC Oracle support

Oracle books by Rampant

Oracle monitoring software

 

 

 

 

 

 

 

 

 

BC Remote Oracle Support

Remote DBA

Remote DBA Services

Copyright © 1996 -  2013 by Burleson. All rights reserved.

Oracle® is the registered trademark of Oracle Corporation.