Refer to two better documents.
Http://nic.qhu.edu.cn/data/2005/0907/article_41.htm
Http://lostinmymind.blogchina.com/2239184.html
There are probably two kinds of crontab, one is to modify the global configuration file/etc/crontab, the other is to run the command crontab-e directly.
Global configuration does not have detailed test, it seems to run directly crontab-e convenient.
1. Execute command crontab-e, at this time the system will open a VI editor.
2. Input
* * */home/bakuplog.sh
Indicates that the script bakuplog.sh is run 23:59 every day. The previous time format is "M H d d cmd". Of which, M stands for minutes (0~59), H stands for hours (0~23), D stands for days (1~31), M for month (1~12), D for days of the week (0~6,0 for Sunday). * represents any. For example 01 * * * * indicates 01 minutes per hour.
3. Edit vi/home/bakuplog.sh, Enter script
#!/bin/sh
mv/var/log/pix.log/var/log/back/
#移动日志
Service Syslog Restart
#重启服务
Gzip-9/var/log/back/pix.log
#压缩
Mv/var/log/back/pix.log.gz/var/log/back/log ' Date +$ (date|cut-c 25-28)%m%d '. gz
#更名
# ' Date +$ (date|cut-c 25-28)%m%d ' indicates the system date, month and year. Note that the symbol ' is not a single quote, which is the key below ESC.
OK, the test succeeded under CentOS 3.4. The result is log20051111.gz.