nginx日志切割

发现nginx的日志没有正常的切割

cat logrotate.d/nginx

1
2
3
4
5
6
7
8
/home/log/nginx1 .0.11/*.log{
     daily
     rotate 30
     copytruncate
     missingok
     notifempty
     compress
}

参照http://wiki.nginx.org/LogRotation

1
2
3
4
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为

 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
/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脚本结束
}

执行

1
/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

从容关闭工作进程



      本文转自天山三害 51CTO博客,原文链接:http://blog.51cto.com/skybug/1346529,如需转载请自行联系原作者






评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值