我试图让logrotate在我的VPS上工作,以每周轮换我的apache文件。当前apache2配置文件的内容是这样的。
"/var/www/user/site.com/logs/*.log" {
weekly
missingok
rotate 8
compress
delaycompress
notifempty
create 640 root adm
sharedscripts
postrotate
/etc/init.d/apache2 reload > /dev/null
endscript
}
我已经离开它两个星期了,据我所知,没有任何变化。当我从命令行模拟它时,将得到以下输出。
user@geneva:/var/lib/logrotate$ /usr/sbin/logrotate -d /etc/logrotate.d/apache2
reading config file /etc/logrotate.d/apache2
reading config info for "/var/www/user/site.com/logs/*.log"
Handling 1 logs
rotating pattern: "/var/www/user/site.com/logs/*.log" weekly (8 rotations)
empty log files are not rotated, old logs are removed
considering log /var/www/user/site.com/logs/access.log
log does not need rotating
considering log /var/www/user/site.com/logs/error.log
log does not need rotating
not running postrotate script, since no logs were rotated
关于Iv配置错误的任何想法?
我的状态文件也为空:(
user@geneva:~$ cat /var/lib/logrotate/status
logrotate state -- version 2
更新资料
我删除了状态文件并强制执行logrotate,现在日志看起来像已经旋转了,状态文件看起来更有希望!
sudo rm /var/lib/logrotate/status
sudo /usr/sbin/logrotate -f /etc/logrotate.conf