2 linux nginx log-files web-server logrotate
我想保留/归档我所有的 Web 服务器日志,并且不让 logrotate 删除任何日志。推荐的方法是什么?这是一个运行 Nginx 的 Linux 机器。提前致谢。
(我更喜欢使用 cronolog,但由于 Nginx 处理日志记录的方式,它似乎与 Nginx 不兼容。)
用 logrotate 来做,告诉它你想要什么......
/var/log/nginx/*.log {
daily
dateext
missingok
rotate 7305 # 2 decades
olddir /var/log/nginx/old
compress
delaycompress
notifempty
create 644 nginx root
sharedscripts
postrotate
if [ -f /var/run/nginx.pid ]; then
kill -USR1 `cat /var/run/nginx.pid`
fi
endscript
}
Run Code Online (Sandbox Code Playgroud)
我不使用 nginx,所以我使用了我为 postrotate 找到的一个例子......如果你已经有一个 logrotate 脚本,请从修改它开始。
关键部分:
归档时间: |
|
查看次数: |
4951 次 |
最近记录: |