利用logrotate切割nginx日志
2013-04-05 21:39
791 查看
为了防止nginx日志日积月累变得很大而不方便查看管理,我们需要用logrotate对nginx的日志按照日期进行归档,以备查看分析nginx的访问记录等信息。
编辑/etc/logrotate.conf文件
创建一个nginx文件
增加以下内容
强制生成一次日志信息
查看生产的日志,发现日志已经切割了
本文出自 “老徐的私房菜” 博客,谢绝转载!
编辑/etc/logrotate.conf文件
# see "man logrotate" for details # rotate log files weekly daily # keep 4 weeks worth of backlogs rotate 4 # create new (empty) log files after rotating old ones create # use date as a suffix of the rotated file dateext # uncomment this if you want your log files compressed #compress # RPM packages drop log rotation information into this directory include /etc/logrotate.d # no packages own wtmp and btmp -- we'll rotate them here /var/log/wtmp { monthly create 0664 root utmp minsize 1M rotate 1 } /var/log/btmp { missingok monthly create 0600 root utmp rotate 1 } # system-specific logs may be also be configured here.
创建一个nginx文件
# ll /etc/logrotate.d/nginx -rw-r--r-- 1 root root 246 4月 5 20:09 /etc/logrotate.d/nginx
增加以下内容
/usr/local/nginx/logs/*.log { daily rotate 31 missingok notifempty nocompress postrotate /bin/kill -USR1 $(cat /usr/local/nginx/logs/nginx.pid 2>/dev/null) 2>/dev/null || : endscript }
强制生成一次日志信息
logrotate -f /etc/logrotate.conf
查看生产的日志,发现日志已经切割了
本文出自 “老徐的私房菜” 博客,谢绝转载!
相关文章推荐
- nginx利用logrotate日志切割
- 利用Centos6系统自带的logrotate切割nginx日志
- logrotate日志管家来切割日志(tomcat,nginx,httpd的日志)
- 使用logrotate做的nginx日志切割
- logrotate 切割 nginx php mysql 日志
- logrotate切割nginx日志
- 利用logrotate系统工具切割tomcat日志
- 利用logrotate系统工具切割tomcat日志
- 利用logrotate来切割日志
- nginx日志切割工具logrotate若干问题
- 切割日志(mysql,nginx,php tomcat)使用logrotate
- apache与nginx 日志切割
- Nginx实战(三) 日志配置与切割
- 日志管理- Logrotate 日志切割和转存
- 12.10 Nginx访问日志 12.11 Nginx日志切割 12.12 静态文件不记录日志和过期时间
- nginx 日志切割脚本
- awstats 统计 nginx日志切割
- nginx日志切割
- Nginx实现大日志文件切割
- nginx日志切割配置