Projects - Cron - Crontab
Cron is the name of program that enables unix users to execute commands or scripts (groups of commands) automatically at a specified time/date. I use Cron to do some backup or upload stuffs at a specified time.
It's very easy to use cron, and the command we use is crontab, you can use #man crontab to know more about it, but the basic usage is:
crontab [-u user] -e -l -r -u: user -e: edit crontab file -l: list crontab file -r: remove crontab file
The step to set up your own crontab file are:
# Format and Range: # minute hour day month week command[script] # 1~59 1~23 1~31 1~12 0~6 command[script] # #(put your own initials here) echo the date to the console every #15 minutes between 6pm and 6am 0,15,30,45 18-06 * * * /bin/echo 'date' > /dev/console
#su user #crontab usercron
crontab it will make a copy of the crontab file in /var/spool/cron/crontab/ with user as its name, check it out then.# crontab # cron # format: minute hour day month week command # range: 1~59 1~23 1~31 1~12 0~6 # flyzhycron # by Haiyong Zheng # website: http://www.flyzhy.org # # backup bbs Data of Dreamers.Com.Cn 28 14 * * * /home/flyzhy/bin/backup-dreamers-bbs.sh # # upload bookmarks from my firefox automatically 28 15 * * * /home/flyzhy/bin/upload-bookmarks.sh # # backup config files from the system 28 20 * * * /home/flyzhy/bin/backup-config-files.sh
Wait for something happen amazing now. ^_^
1. Notice that the command[script] must be the absolute position like /bin/echo but not just echo.