View Single Post

  #1 (permalink)  
Old 06-12-2007, 03:31 AM
sweta's Avatar
sweta sweta is offline
Contributors
User
 
Join Date: Feb 2005
Location: New Delhi
My distro: Suse, RHEL, Vista
Posts: 154
Rep Power: 4
sweta will become famous soon enough
Post How do I configure Linux UNIX cron tasks?

This is a common question asked by many user and here is the answer:

/etc/contab is main configuration file.

Each line in the /etc/crontab file represents a task and has the following format:

Code:
minute hour day month dayofweek command
Understanding possible valid values:
minute - any integer from 0 to 59
hour - any integer from 0 to 23
day - any integer from 1 to 31 (must be a valid day if a month is specified)
month - any integer from 1 to 12 (or the short name of the month such as jan or feb)
dayofweek - any integer from 0 to 7, where 0 or 7 represents Sunday (or the short name of the week such as sun or mon)
command - the command to execute or a shell script

For any of the above values, an asterisk (*) can be used to specify all valid values. For example, an asterisk for the month value means execute the command every month within the constraints of the other values.

A hyphen (-) between integers specifies a range of integers. For example, 6-10 means the integers 6,7,8,9 and 10

A list of values separated by commas (,) specifies a list. For example, 3, 4, 6, 8 indicates those four specific integers.

The forward slash (/) can be used to specify step values. For example, 0-59/ can be used to define every other five minute in the minute field.

Any lines that begin with a hash mark (#) are comments and are not processed.


To create a crontab as a user, login as that user and type the command crontab -e to edit the user's crontab
Code:
crontab -e
To run command foo every friday type
Code:
30 3 * * fri /path/to/foo
__________________
Friends - v-nessa - missyAdmin - LinuxChix
Reply With Quote