Linux下处理日志,可以使用logrotate
对应的配置文件在/etc/anacrontab
看一下配置文件情况:
1 # /etc/anacrontab: configuration file for anacron
2
3 # See anacron(8) and anacrontab(5) for details.
4
5 SHELL=/bin/sh
6 PATH=/sbin:/bin:/usr/sbin:/usr/bin
7 MAILTO=root
8 # the maximal random delay added to the base delay of the jobs
9 RANDOM_DELAY=45
10 # the jobs will be started during the following hours only
11 START_HOURS_RANGE=3-22
12
13 #period in days delay in minutes job-identifier command
14 1 5 cron.daily nice run-parts /etc/cron.daily
15 7 25 cron.weekly nice run-parts /etc/cron.weekly
16 @monthly 45 cron.monthly nice run-parts /etc/cron.monthly
配置文件确定的是定期去执行
logrotate对应的每个程序的配置文件在/etc/logrotate.d中
以apache的为例
/var/log/httpd/*log {
missingok
notifempty
sharedscripts
delaycompress
postrotate
/sbin/service httpd reload > /dev/null 2>/dev/null || true
endscript
}