Wednesday, June 11, 2014

Cron Job Configuration in unix

Cron

 
This is an utility using that we can schedule job on unix system.
 
This we can use an alternative for scheduling concurrent programs at application level. Means we can schedule an unix script which will submit concurrent program on application after particulor interval.
 
Cron is driven by a crontab (cron table) file, a configuration file that specifies shell commands to run periodically on a given schedule. Every user can have their own cron tab file.
 
Note: DBA/Unix administrator can help or provide information to understand or configuring crons as these are scheduled at unix level.
 
Cron Example-
 
00,15,30,45 * * * 1-6 /fprdappl/ocgl/11.5.0/bin/gl_load.sh
25,55 07-19 * * 1-6 /fprdappl/ocap/11.5.0/bin/ap_load.sh
15,35,55 08-22 * * 1-6 /home/applmgr/scripts/listing.sh
 
 
Scheduling Options:
 
# * * * * *  script to execute(need to provide path if location of is different)
# │ │ │ │ │
# │ │ │ │ └-day of week (0 - 6) (0 to 6 are Sunday to Saturday)
# │ │ │ └month (1 - 12)
# │ │ └ day of month (1 - 31)
# │ └ hour (0 - 23)
# └min (0 - 59)
 
Cron String-
 
A CRON expression is a string comprising five or six fields separated by white space that represents a set of times, normally as a schedule to execute some routine.

Format-




Field name
Mandatory?

Allowed values

Allowed special characters

Minutes

Yes

0-59

* / , -
 

Hours

Yes

0-23

* / , -
 

Day of month

Yes

1-31

* / , - ? L W
 

Month

Yes

1-12 or JAN-DEC

* / , -
 

Day of week

Yes

0-6 or SUN-SAT

* / , - ? L #
 
   



Special character
Asterisk ( * )
The asterisk indicates that the cron expression matches for all values of the field. E.g., using an asterisk in the 4th field (month) indicates every month.
Slash ( / )
Slashes describe increments of ranges. For example 3-59/15 in the 1st field (minutes) indicate the third minute of the hour and every 15 minutes thereafter. The form "*/..." is equivalent to the form "first-last/...", that is, an increment over the largest possible range of the field.
Comma ( , )
Commas are used to separate items of a list. For example, using "MON,WED,FRI" in the 5th field (day of week) means Mondays, Wednesdays and Fridays.
Hyphen ( - )
Hyphens define ranges. For example, 2000-2010 indicates every year between 2000 and 2010 AD, inclusive.
Percent ( % )
Percent-signs (%) in the command, unless escaped with backslash (\), are changed into newline characters, and all data after the first % are sent to the command as standard input.


No comments:

Post a Comment