作者/来源:yixinu.com
栏目:运维/编程
日期:2012-04-18 06:29:03
cron.d/ 包含额外的计划任务文件
cron.daily/ 该文件夹下文件,每天扫描执行一次
cron.hourly/ 该文件夹下文件,每小时扫描执行一次
cron.monthly/ 该文件夹下文件,每月扫描执行一次
crontab 周期性计划任务配置文件
cron.weekly/ 该文件夹下文件,每周扫描执行一次
在6.0的系统中手动写,要不然会按系统默认时间执行
example:
[root@bogon etc]# vim /etc/crontab SHELL=/bin/bash PATH=/sbin:/bin:/usr/sbin:/usr/bin MAILTO=root HOME=/ # For details see man 4 crontabs # Example of job definition: # .---------------- minute (0 - 59) # | .------------- hour (0 - 23) # | | .---------- day of month (1 - 31) # | | | .------- month (1 - 12) OR jan,feb,mar,apr ... # | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat # | | | | | # * * * * * command to be executed #01 * * * * run-parts /etc/cron.hourly 59 23 * * * run-parts /etc/cron.daily #59 23 * * 1 run-parts /etc/weekly #59 23 1 * * run-parts /etc/monthly
logrotate
是一个循环、压缩,心及邮寄系统日志的系统程序,例如 ,一台服务器一周的日志文件可能达到上百MB,这就需要自动分割了
配置文件:/etc/logrotate.conf
[root@bogon etc]# vim /etc/logrotate.conf # see "man logrotate" for details # rotate log files weekly weekly 以周为单位产生新文件 # keep 4 weeks worth of backlogs rotate 4 最少保留4周的日志文件 # create new (empty) log files after rotating old ones create 处理完后创建一个新的空日志文件 # use date as a suffix of the rotated file dateext 使用日期作为后缀来循环 # uncomment this if you want your log files compressed #compress 将旧日志 文件压缩 # RPM packages drop log rotation information into this directory include /etc/logrotate.d # no packages own wtmp and btmp -- we'll rotate them here
这个文件不按上面的规则循环 /var/log/wtmp { monthly 以月为单位 create 0664 root utmp 文件权限 minsize 1M 最小为1M ,如果不够1M 则1个月时间 到了,也不会循环 rotate 1 1个月循环一次 maxsize 10M 最大为10M ,如果时间不到1个月,但文件大小已经到达10M,则循环 } /var/log/btmp { missingok monthly create 0600 root utmp rotate 1 }