zoukankan      html  css  js  c++  java
  • Nginx 日志切割(Logrotate)

    Logrotate 配置文件

    # ls /etc/logrotate.*
    /etc/logrotate.conf
    
    /etc/logrotate.d:
    cups  dracut  fmdcn  httpd  iptraf  monit  psacct  puppet  sssd  syslog  yum  zabbix-agent

    /etc/logrotate.conf 是 logrotate 的配置文件。

    /etc/logrotate.d/ 是用于存储其他配置文件的目录。该目录里的所有文件都会被主动的读入 /etc/logrotate.conf。

    配置 Logrotate 只需要在 /etc/logrotate.d/  新建一个文件,示例:

    vim /etc/logrotate.d/fmdcn

    /cache/cache/logs/fmdcn/*.log{  # /cache/cache/logs/fmdcn/*.log 为需要切割的日志路径
    daily  # 日志文件将按天轮询,也可以是weekly, monthly
    missingok  # 在日志轮询期间,任何错误将被忽略
    dateext  # 定义日志文件后缀是日期格式,error.log-20170928
    compress  # 在轮循任务完成后,已轮循的归档将使用 gzip 进行压缩
    delaycompress  # 不将最近的归档压缩,压缩将在下一次轮询周期进行
    rotate 30  # 保存 30 个日志文件,后续切割文件时,将时间最久的日志文件删除
    notifempty  # 如果是空文件的话,不进行转储
    create 640 root adm  # 以指定的权限和用户属性创建新的日志文件
    sharedscripts  # when telling nginx that logs have been rotated, only do it once rather than once for each file group 
    postrotate   # postrotate/endscript 在所有其它指令完成后,postrotate和endscript里面指定的命令将被执行
            [ ! -f /FastwebApp/fmdcn/nginx/logs/nginx.pid ] || kill -USR1 `cat /FastwebApp/fmdcn/nginx/logs/nginx.pid`
    endscript
    # postrotate 命令块发送一个信号到 nginx,告诉它日志已经被轮循,nginx 应该使用新的本件句柄
    }

    配置检查:
    logrotate -d /etc/logrotate.d/fmdcn

    运行后将显示 debug 信息

    立即生效:

     logrotate -f -v /etc/logrotate.d/fmdcn

  • 相关阅读:
    小程序登陆流程解析
    小程序连续点击bug解决
    小程序开发文本空格的添加
    微信小程序转支付宝小程序
    支付宝小程序开发入门
    微信小程序开发入门
    text属性
    小程序横向滚动
    will-change
    Docker 系列二(操作镜像).
  • 原文地址:https://www.cnblogs.com/DillGao/p/7605521.html
Copyright © 2011-2022 走看看