Databases Reference
In-Depth Information
Don't schedule the jobs that you enter in cron to run all at the same time. rather, spread them out so as not to
bog down cron or the system at any particular point in time.
Tip
Scheduling a Job to Run Automatically
To schedule a job, you must add a line in your cron table, specifying the time you want the job to execute. There are
two methods for adding entries in your cron table:
cron table file directly
Editing the
cron table from a file
Loading the
These two techniques are described in the following sections.
Editing the cron Table Directly
You an edit your cron table directly with the -e (editor) option of the crontab command:
$ crontab -e
When issuing the previous command, you will be presented with a file to edit. This file is known as your cron
table ( crontab ). To schedule a script named backup.bsh to run daily, at 11:05 pm, enter the following line into your
cron table:
5 23 * * * /home/oracle/bin/backup.bsh
Here, the 5 specifies that the job will run at 5 minutes after the top of the hour. The 23 is military time, specifying
that the job should run in the 2300 hour window (in this example, 5 minutes after the hour). The three stars ( * * * )
signify that the job should run every day of the month, every month of the year, and every day of the week.
Exit the cron table file. If your default editor is vi , then type wq to exit. When you exit crontab , your cron table is
saved for you. To view your cron entries, use the -l (list) option of the crontab command:
$ crontab -l
To remove your cron table completely, use the r option:
$ crontab -r
Before running the previous command, you should save your cron table in a text file, as shown:
$ crontab -l > saved.cron
In this way, you can refer to the saved file, in the event that you didn't mean to delete your cron table.
Tip
I once worked with a Dba who thought crontab -r meant “read the cron table.” Don't ever make that mistake.
 
 
Search WWH ::




Custom Search