Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
File 需要了解logrotate行为方面的帮助吗_File_Logrotate - Fatal编程技术网

File 需要了解logrotate行为方面的帮助吗

File 需要了解logrotate行为方面的帮助吗,file,logrotate,File,Logrotate,/etc/logrotate.conf说rotate日志“每周” /etc/logrotate.d/ssh说 /var/log/ssh.log { compress dateext maxage 120 rotate 99 missingok notifempty size +4096k create 640 root p4admin sharedscripts postrotate /etc/init.d/syslog reload endscript } /var/lib/logrotat

/etc/logrotate.conf说
rotate日志“每周”

/etc/logrotate.d/ssh说

/var/log/ssh.log {
compress
dateext
maxage 120
rotate 99
missingok
notifempty
size +4096k
create 640 root p4admin
sharedscripts
postrotate
/etc/init.d/syslog reload
endscript
}
/var/lib/logrotate.status显示“/var/log/ssh.log”2013-1-4上最后一次旋转的ssh

但是上面的数据与我们在文件上看到的不匹配

-rw-r----- 1 root user 201M Jan 4 09:47 /var/log/ssh.log
-rw-r----- 1 root user 65M Oct 19 04:02 /var/log/ssh.log-20121019.gz
-rw-r----- 1 root user 64M Nov 28 04:02 /var/log/ssh.log-20121128.gz
-rw-r----- 1 root user 63M Oct 23 04:02 /var/log/ssh.log-20121023.gz
知道我遗漏了什么吗?

  • /etc/logrotate.conf
    中的
    weekly
    表示如果本地未覆盖此选项,则所有日志文件都将每周旋转一次

    手册上说:

    Each configuration file can set global options (local definitions over-
    ride global ones, and later  definitions  override  earlier  ones)  and
    specify  logfiles  to  rotate.
    
    Normally, logrotate is run as a daily cron job.  It will not  modify  a
    log  multiple  times  in  one  day unless the criterion for that log is
    based on the log's size and logrotate is being run multiple times  each
    day, or unless the -f or --force option is used.
    
  • 如果使用了
    大小
    选项,logrotate将忽略所述的
    每日
    每周
    每月
    年度
    选项

  • 每天执行logrotate以检查大小等标准。如果适用,日志将同时轮换

    手册上说:

    Each configuration file can set global options (local definitions over-
    ride global ones, and later  definitions  override  earlier  ones)  and
    specify  logfiles  to  rotate.
    
    Normally, logrotate is run as a daily cron job.  It will not  modify  a
    log  multiple  times  in  one  day unless the criterion for that log is
    based on the log's size and logrotate is being run multiple times  each
    day, or unless the -f or --force option is used.
    
因此,logrotate每天都会检查日志的大小,并在必要时执行旋转