What are the meanings of parameters on a Cron Entry?
When we schedule a job in the Unix Server, we insert an entry in the CronTab.
A typical Cron Entry will look like below:
* * * * * Command to execute
Below image defines the meaning of each parameter.
There are several special predefined values which can be used to substitute the CRON expression.
Here are some examples to understand usage of the parameters in Cron entry:
1. Cron script1.ksh to run at 02:10 AM everyday
10 02 * * * script1.ksh
2. Cron script2.ksh to run every hour at the 30th minute
30 * * * * script2.ksh
3. Cron script3.ksh to run twice daily, once at 01:10 and second at 13:10
10 01,13 * * * script3.ksh
4. Cron script4.ksh to run at 0th, 1st, 2nd, 3rd, 4th, 5th minute of each hour
00,01,02,03,04,05 * * * * script4.ksh
5. Cron script5.ksh to run at 4th minute of every 2 hours eg 00:04, 02:04, 04:04, 06:04 etc
04 */2 * * * script5.ksh
The below reference template can be added at the top of a crontab for easy reference.
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .----- day of week (0 - 7) (Sunday=0 or 7)
# | | | | | OR sun,mon,tue,wed,thu,fri,sat
# * * * * * command to be executed
For more Unix Tips, Click here.
When we schedule a job in the Unix Server, we insert an entry in the CronTab.
A typical Cron Entry will look like below:
* * * * * Command to execute
Below image defines the meaning of each parameter.
1. Cron script1.ksh to run at 02:10 AM everyday
10 02 * * * script1.ksh
2. Cron script2.ksh to run every hour at the 30th minute
30 * * * * script2.ksh
3. Cron script3.ksh to run twice daily, once at 01:10 and second at 13:10
10 01,13 * * * script3.ksh
4. Cron script4.ksh to run at 0th, 1st, 2nd, 3rd, 4th, 5th minute of each hour
00,01,02,03,04,05 * * * * script4.ksh
5. Cron script5.ksh to run at 4th minute of every 2 hours eg 00:04, 02:04, 04:04, 06:04 etc
04 */2 * * * script5.ksh
The below reference template can be added at the top of a crontab for easy reference.
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .----- day of week (0 - 7) (Sunday=0 or 7)
# | | | | | OR sun,mon,tue,wed,thu,fri,sat
# * * * * * command to be executed
For more Unix Tips, Click here.
No comments:
Post a Comment
Please give your feedback, questions and suggestions. I will surely answer you.