Академический Документы
Профессиональный Документы
Культура Документы
Syntax of Cron:
[min] [hour] [day of month] [month] [day of week] [program to be
run]
[min] Minutes that program should be executed on. 0-59. (Do
not set as * or the program will be run once a minute).
[hour] Hour that program should be executed on. 0-23. (* for
every hour).
[day of month] Day of the month that process should be
executed on. 1-31. (* for every day).
[month] Month that program whould be executed on. 1-12 (* for
every month).
[day of week] Day of the week. 0-6 where Sunday = 0, Monday
= 1, ...., Saturday = 6. (* for every day of the week).
[program] Program to be executed. (Include full path
information).
Mailing to user
MAILTO=cron@username.plus.com
Example
MAILTO=NOC@marketlive.com
Crontab commands
options
crontab –e
As explained earlier, this will allow you to edit the contents of your crontab file or
create a new crontab file if one does not already exist. The editor used is called vi or
vim.
crontab -l
This will list the current contents of your crontab file and is very useful for checking you
have edited it correctly after crontab -e. It is often useful to make a copy of the crontab
file in case you make a mistake with an edit.
$ crontab -l > mycrontab
This will create a local copy of the crontab file called mycrontab.
crontab -r
Use with caution: This will delete the contents of your current crontab file (another
reason for making a local copy!)
crontab file
This is an alternative method for setting up your crontab file. Instead of using crontab
-e, you can create a file containing the cron commands and use that to replace or
overwrite the current contents of your crontab file. Note replace - it will overwrite
anything that is currently in your crontab file with the contents of file.
Examples
crontab -e [username]
To schudle the job for particular
user(msuser)
Crontab –u [username] –l
To list the jobs under username
Editing crontab to schedule
the jobs
$Crontab –u msuser –e
Example
Scheduling copying the files from /root to /mnt file.
10 23 21 03 05 /bin/cp /root /mnt