·
The *
means all the possible unit — i.e every minute of every hour through out the
year. More than using this * directly, you will find it very useful in the
following cases
·
Please note that the time field uses 24 hours
format. So, for 11 AM use 11, and for 11 PM use 23.
How to View Crontab Entries?
View Current Logged-In User’s Crontab entries
To view your crontab entries type crontab -l from your unix account as shown below.
oracle@servername$crontab –l
· How to Edit Crontab Entries ?
We can add or edit crontab entries by typing crontab –e in unix prompt as shown below
oracle@servername$crontab –e
Some Exmples are given below:
·
Example
1. Job to Run Once a day except Sunday
The
basic usage of the job is to run once day as show below. This will take
incremental backup everyday except Sunday on 10:30 PM
30 10 * *
1,2,3,4,5,6 /u01/app/oracle/backup/L1-backup
§ 30 – 30th Minute
§ 22 – 10 PM
§ * – Everyday
§ * – All month (Jan)
§ 1-6 – Every day of the week
execpt sunday
Example 2. Job to Run On
Every Sunday
The
basic usage of cron is to execute a job on Every as shown below. This will
execute the Full backup shell script (full-backup) on sunday 12:30 AM.
30 00 * *
0 /u01/app/oracle/backup/full-backup
§ 30 – 30th Minute
§ 00 – 12 AM
§ * – Any day of month
§ * – All Month
§ 0 – Run On Sunday
Example 3. Job To Run Specific
Time
The
basic usage of cron is to execute a job in a specific time as shown below. This
will execute the Full backup shell script (full-backup) on 28th Jan 12:30 AM.
30 00 28
01 * /u01/app/oracle/backup/full-backup
§ 30 – 30th Minute
§ 00 – 12 AM
§ 28 – 28th Day
§ 01 – 1th Month (Jan)
§ * – Every day of the week
Example 4. Job To Run More Than
One Instance (e.g. Twice a Day)
The
following script take a incremental backup twice a day every day.
This example executes the specified incremental backup shell script (incremental-backup) at 11:00 and 16:00 on every day. The comma separated value in a field specifies that the command needs to be executed in all the mentioned time.
This example executes the specified incremental backup shell script (incremental-backup) at 11:00 and 16:00 on every day. The comma separated value in a field specifies that the command needs to be executed in all the mentioned time.
00 11,16 *
* * /u01/app/oracle/backup/bin/incremental-backup
§ 00 – 0th Minute (Top of the
hour)
§ 11,16 – 11 AM and 4 PM
§ * – Every day
§ * – Every month
§ * – Every day of the week
Example 5. Job To Run Specific
Range of Time (e.g. Only on Weekdays)
If you wanted a job to be scheduled for every
hour with in a specific range of time then use the following.
Cron
Job everyday during working hours
This example checks the status of the database
everyday (including weekends) during the working hours 9 a.m – 6 p.m
00 09-18 *
* * /u01/app/oracle/backup/bin/check-db-status
§ 00 – 0th Minute (Top of the
hour)
§ 09-18 – 9 am, 10 am,11 am, 12
am, 1 pm, 2 pm, 3 pm, 4 pm, 5 pm, 6 pm
§ * – Every day
§ * – Every month
§ * – Every day of the week
Cron
Job every weekday during working hours
·
