nginx 使用 logrotate 回滚日志

2009-09-04  15:28  |  分类:应用技术  |  标签:  |  499 次浏览

vi /usr/local/nginx/conf/logrotate.conf

/var/log/nginx/*.log {
    daily
    missingok
    rotate 7
    compress
    delaycompress
    notifempty
    create 640 www-data adm
    sharedscripts
    prerotate
    sleep 59
    endscript
    postrotate
        if [ -f /var/run/nginx.pid ]; then
          kill -USR1 `cat /var/run/nginx.pid`
        fi
    endscript
}

调试:
logrotate -d /usr/local/nginx/conf/logrotate.conf

执行:
logrotate -f /usr/local/nginx/conf/logrotate.conf

定期执行:
vi /etc/crontab
59 23 * * * root logrotate -f /usr/local/nginx/conf/logrotate.conf

喜欢本文,那就收藏到: Del.icio.us Google书签 Digg Live Bookmark Technorati Furl Yahoo书签 Facebook 百度搜藏 新浪ViVi 365Key网摘 天极网摘 和讯网摘 博拉网 POCO网摘 添加到饭否 QQ书签 Digbuzz我挖网

发表您的评论