As you can see, cron is very useful. Oracle Database Administrators
use cron often to schedule jobs automatically.
Typically, such activities are performed at night when the system load is low. From a database standpoint, we can use cron to perform backups of the database every night or we can run SQL reports that will spool output files every night to keep track of system usage.
first * --> Indicates Minute of Hour(1,2,3..59,60)
Second * --> Indicates Hour of Day(1,2,3.....23,24)
Third * --> Indicates Day of Month(1,2,3....30,31)
Fourth * --> Indicates Month of Year(1,2,....11,12)
Fifth * --> Indicates day of week Mean Sun,Mon....Sat (0-Sun,1-Mon,2-Tue,3-Wed,4-Thu,5-Fri,6-Sat)
or
Ex: 00 01 8-14 * 6 /app/my_saturday_job.sh
if Day of week=Saturday(6) otherwise won't execute
Because Second saturday must be in between the dates
8-14Days
or
Ex: 00 01 1-7,15-21 * 6 /app/my_saturday_job.sh
Explanation: Executes the script from 1 to 7 and 15-21 every day if Day of week=Saturday(6) otherwise not execute
Because First saturday must be in between interval dates of 1-7Days and Third Saturday Must be in interval dates of 15-21
###################################################### All The Best ######################################################
use cron often to schedule jobs automatically.
Typically, such activities are performed at night when the system load is low. From a database standpoint, we can use cron to perform backups of the database every night or we can run SQL reports that will spool output files every night to keep track of system usage.
1.Crontab Example:
* * * * *first * --> Indicates Minute of Hour(1,2,3..59,60)
Second * --> Indicates Hour of Day(1,2,3.....23,24)
Third * --> Indicates Day of Month(1,2,3....30,31)
Fourth * --> Indicates Month of Year(1,2,....11,12)
Fifth * --> Indicates day of week Mean Sun,Mon....Sat (0-Sun,1-Mon,2-Tue,3-Wed,4-Thu,5-Fri,6-Sat)
2.How to schedule jobs on Second Saturday
Ex: 00 01 8,9,10,11,12,13,14 * 6 /app/my_saturday_job.shor
Ex: 00 01 8-14 * 6 /app/my_saturday_job.sh
- Above jobs will run on every second saturday at 1AM-1minute
- 8-14 or 8,9,10,11,12,13,14 Indicates Days of month
- * Indicates every month
- 6 Indicates Saturday
if Day of week=Saturday(6) otherwise won't execute
Because Second saturday must be in between the dates
8-14Days
3.How to schedule jobs on Every First & Third Saturday
Ex: 00 01 1,2,3,4,5,6,7,15,16,17,18,19,20,21 * 6 /app/my_saturday_job.shor
Ex: 00 01 1-7,15-21 * 6 /app/my_saturday_job.sh
- Above job will run on every First & Third saturday at 1AM-1minute
- 1-7 and 15-21 Means Days of month
- * Indicates every month
- 6 Indicates Saturday
Explanation: Executes the script from 1 to 7 and 15-21 every day if Day of week=Saturday(6) otherwise not execute
Because First saturday must be in between interval dates of 1-7Days and Third Saturday Must be in interval dates of 15-21
###################################################### All The Best ######################################################
Nice explanation
ReplyDelete