Last active
May 10, 2016 16:00
-
-
Save safecat/e3764e1eb670a05f3f0e to your computer and use it in GitHub Desktop.
Nginx log rotate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 日志切割时间 | |
vi /etc/crontab | |
# 把cron.daily的时间改为0 0 | |
# 日志切割文件存储格式 | |
vi /etc/logrotate.d/nginx | |
/var/log/nginx/*.log { | |
daily | |
missingok | |
rotate 52 | |
compress #重要 | |
dateformat %Y%m%d. #重要 | |
dateext #重要 | |
extension log #文件扩展名 | |
notifempty | |
create 0640 deploy deploy #重要 | |
sharedscripts | |
prerotate | |
if [ -d /etc/logrotate.d/httpd-prerotate ]; then \ | |
run-parts /etc/logrotate.d/httpd-prerotate; \ | |
fi; \ | |
endscript | |
postrotate | |
[ ! -f /var/run/nginx.pid ] || kill -USR1 `cat /var/run/nginx.pid` | |
endscript | |
} | |
# 调试命令 | |
sudo /usr/sbin/logrotate --force /etc/logrotate.conf |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment