Tips Using Crontab to Create Schedule Jobs
Crontab is a program that allows users to create jobs that will run at a given time. Each individual user has their own crontab and the entire system has a crontab that can only be modified using root access. If you are adding a crontab for an individual user you must sign on as that user first.
Options:
* crontab -e – Edits the current crontab or creates a new one.
* crontab -l – Lists the contents of the crontab file.
* crontab -r – Removes the crontab file.
There are six fields for each entry, each separated by a space or tab.
* The first five fields specify when the command is to be run
* Sixth field is the command itself.
Minute – 0-59
Hour – 0-23 24-hour format
Day – 1-31 Day of the month
Month – 1-12 Month of the year
Weekday – 0-6 Day of the week. 0 refers to Sunday
Time formats…
Every instance – An asterisk (*) is used to indicate that every instance (i.e. every hour, every weekday, etc.) of the particular time period will be used.
Example: * 23 * * * – Executes at 11PM every day
List – If you wish to use more than one instance of a particular time periods, then seperate the values by a comma.
Example: 5,35 * * * 1-5 – Executes at :05 and :35 past the hour, every hour, Monday through Friday
Range – If you wish for continuous execution, the start and stop items are separated by a dash.
Example: 8-11 – For an hours entry executes at hours 8, 9, 10 and 11
Step – Step values can be used in conjunction with ranges. Following a range with / specifies skips of the number’s value through the range. Steps are also permitted after an asterisk
Example: 0-23/2 – In the hours field executes every other hour
Example: 1-9/2 – Is the same as 1,3,5,7,9
Example: */2 – Executes every two hours
Names – Can be used for the month and day of week fields. Use the first three letters of the particular day or month (case doesn’t matter). Ranges or lists of names are not allowed.
When specifying day of week, both day 0 and day 7 will be considered Sunday.
Command – The last entry specifies the actual script to execute. Make sure you enter the full path name for the command. Also make sure your script has a full path name references to files or other programs or scripts that it may execute.
Source : http://www.ahinc.com/linux101/utilities.htm
Popular Tags for the article:
ubuntu lucid cron, lucid crontab, ubuntu lucid crontab, lucid cron, crontab ubuntu run monday through friday, mikrotik cron, mikrotik cron script, sample cron job script for miktrotik, ubuntu 10 4 crontabRelated posts:


