zoukankan      html  css  js  c++  java
  • Nginx日志按天分割

    核心思想:使用crontab在每日23:59执行日志分割。

    1、配置nginx日志信息,vim /etc/logrotate.d/nginx

    /var/log/nginx/*.log {
        nocompress
        daily
        copytruncate
        create
        notifempty
        rotate 7
        olddir /var/log/nginx
        missingok
        dateext
        postrotate
            /bin/kill -HUP `cat /var/run/nginx.pid 2> /dev/null` 2> /dev/null || true
        endscript
    }

    2、配置crontab,vim /etc/crontab或者执行crontab -e添加如下信息:

    59 23 * * * root ( /usr/sbin/logrotate -f /etc/logrotate.d/nginx)

    3、重启cron

    service cron restart
  • 相关阅读:
    Intern Day42
    Intern Day42
    Intern Day42
    Intern Day40
    腾讯PC客户端二面
    面试
    面试
    面试
    计算机网络
    计算机网络
  • 原文地址:https://www.cnblogs.com/wangzhigang/p/5333132.html
Copyright © 2011-2022 走看看