zoukankan      html  css  js  c++  java
  • Linux中的日志功能

    配置文件 /etc/logrotate.conf 
    daily
      日志的轮替周期是每天
    weekly
      日志的轮替周期是每周
    monthly
      日志的轮替周期是每月
    rotate 数字
      保留的日志文件的个数
    compress
      日志轮替时旧的日志进行压缩
    create mode owner group
      建立新日志,同时指定新日志的权限与所有者和所属组
    mail address
      当日志轮替时,输出内容通过邮件发送到指定邮件地址
    missingok
      如果日志不存在,则忽略该日志的警告信息
    notifempty
      如果日志为空,则不进行日志轮替
    minsize 数字
      日志一定要达到这个最小值才会轮替,否则就算时间到了也不轮替
    size 数字
      日志只有大于指定大小才进行轮替,而不是按照时间轮替
    dateext
      使用日期作为日志轮替文件的后缀


    [root@localhost ~]# cat /etc/logrotate.conf
    # see "man logrotate" for details
    # rotate log files weekly
    weekly

    # 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.
    [root@localhost ~]#

    logrotate [选项] /etc/logrotate.cong
      -v    显示日志轮替的过程
      -f     强制进行一次日志轮替,不论是否已经达到日志轮替的条件

  • 相关阅读:
    [Keyence Programming Contest 2020 E] Bichromization
    [Gym101821B] LIS vs. LDS
    [Ynoi2010]iepsmCmq【数据结构】
    【集训队作业2018】喂鸽子
    【集训队作业2018】复读机
    【NOI2015】荷马史诗
    【IOI2018】组合动作
    【清华集训2017】榕树之心
    【清华集训2016】Alice和Bob又在玩游戏
    1209F
  • 原文地址:https://www.cnblogs.com/413xiaol/p/7224078.html
Copyright © 2011-2022 走看看