发现nginx的日志没有正常的切割
cat logrotate.d/nginx
/home/log/nginx1.0.11/*.log{
daily
rotate 30
copytruncate
missingok
notifempty
compress
}$ mv access.log access.log.0 $ kill -USR1 `cat master.nginx.pid` $ sleep 1 $ gzip access.log.0 # do something with access.log.0
nginx 提供了USR1信号 可重新打开日志
逐修改cat logrotate.d/nginx为
/home/log/nginx1.0.11/*.log{
daily #每日
rotate 30 #保留30天的
copytruncate #用于还在打开中的日志文件,把当前日志备份并截断
missingok #找不到log文件也继续
notifempty #如果文件为空不转储
compress #压缩
dateext #用日期做归档日志的扩展名
postrotate #post脚本开始
if [ -f /var/run/nginx.pid ]; then
kill -USR1 `cat /var/run/nginx.pid`
fi
endscript #post脚本结束
}执行
/usr/sbin/logrotate -f /etc/logrotate.d/nginx
查看日志归档正常
############################nginx信号#############################################
TERM, INT | Quick shutdown | 快速关闭 | ||
QUIT | Graceful shutdown | 从容关闭 | ||
HUP | Configuration reload Start the new worker processes with a new configuration Gracefully shutdown the old worker processe | 重载配置 用新的配置开始新的工作进程 从容关闭旧的工作进程 | ||
USR1 | Reopen the log files | 重新打开日志文件 | ||
USR2 | Upgrade Executable on the fly | 平滑升级可执行程序。 | ||
WINCH | Gracefully shutdown the worker processes | 从容关闭工作进程 | ||
















