b0uncer |
04-11-2008 09:58 AM |
From (try: 'man -k cron')
Quote:
EXAMPLE CRON FILE
# use /bin/bash to run commands, instead of the default /bin/sh
SHELL=/bin/bash
# mail any output to ‘paul’, no matter whose crontab this is
MAILTO=paul
#
# run five minutes after midnight, every day
5 0 * * * $HOME/bin/daily.job >> $HOME/tmp/out 2>&1
# run at 2:15pm on the first of every month -- output mailed to paul
15 14 1 * * $HOME/bin/monthly
# run at 10 pm on weekdays, annoy Joe
0 22 * * 1-5 mail -s "It’s 10pm" joe%Joe,%%Where are your kids?%
23 0-23/2 * * * echo "run 23 minutes after midn, 2am, 4am ..., everyday"
5 4 * * sun echo "run at 5 after 4 every sunday"
|
Oh, and do read the rest of the file for more information. To edit the crontab file,
Quote:
usage: crontab [-u user] file
crontab [-u user] { -e | -l | -r }
(default operation is replace, per 1003.2)
-e (edit user's crontab)
-l (list user's crontab)
-r (delete user's crontab)
|
And lastly, your command would probably look something like
Code:
10 0 * * * cp -r /var/whatever /backup/`date +%m-%d-%y`
if you wanted to run it 00.10 every night. I haven't tried with that date command, but you should, if you plan to use it.
The time fields are (asterisk means "every time"):
minute hour day_of_month month day_of_week
where the weekday is a number from 0-7 where 0 or 7 means typically Sunday, unless you use names.
|