2023年7月3日发(作者:)
Linux⽇志系统-03:logrotate主配置⽂件详解logrotate主配置⽂件详解⼀、logrotate主配置⽂件/etc/# 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 #指定滚动后创建的新⽂件的权限为0644,数组为root,属组为utmp
minsize 1M #指定⽂件的值⼩于1M不滚动
rotate 1 #指定保留⼏个备份副本
}
/var/log/btmp {
missingok #如果⽇志⽂件不存在发送错误消息 monthly create 0600 root utmp rotate 1
}
# system-specific logs may be also be configured here.⼆、主配置⽂件参数详解PS:配置⽂件中的更多参数可⽤man logrotate查看 compress Old versions of log files are compressed with gzip(1) by default. See also nocompress. compresscmd Specifies which command to use to compress log files. The default is gzip(1). See also compress. uncompresscmd Specifies which command to use to uncompress log files. The default is gunzip(1). compressext Specifies which extension to use on compressed logfiles, if compression is enabled. The default follows that of the configured compression command. compressoptions Command line options may be passed to the compression program, if one is in use. The default, for gzip(1), is "-6" (biased towards high compression at the expense of speed). If you use a different compression command, you may need to change the compressoptions to match. copy Make a copy of the log file, but don't change the original at all. This option can be used, for instance, to make a snapshot of the current log file, or when some other utility needs to truncate or parse the file. When this option is used, the create option will have no effect, as the old log file stays in place. copytruncate Truncate the original log file to zero size in place after creating a copy, instead of moving the old log file and optionally creating a new one. It can be used when some program cannot be told to close its logfile and thus might continue writing (appending) to the previous log file forever. Note that there is a very small time slice between copying the file and truncating it, so some log‐ ging data might be lost. When this option is used, the create option will have no effect, as the old log file stays in place. create mode owner group, create owner group Immediately after rotation (before the postrotate script is run) the log file is created (with the same name as the log file just rotated). mode specifies the mode for the log file in octal (the same as chmod(2)), owner specifies the user name who will own the log file, and group specifies the group the log file will belong to. Any of the log file attributes may be omitted, in which case those attributes for the new file will use the same values as the original log file for the omitted attributes. This option can be disabled using the nocreate option. createolddir mode owner group If the directory specified by olddir directive does not exist, it is created. mode specifies the If the directory specified by olddir directive does not exist, it is created. mode specifies the mode for the olddir directory in octal (the same as chmod(2)), owner specifies the user name who will own the olddir directory, and group specifies the group the olddir directory will belong to. This option can be disabled using the nocreateolddir option. daily Log files are rotated every day. dateext Archive old versions of log files adding a date extension like YYYYMMDD instead of simply adding a number. The extension may be configured using the dateformat and dateyesterday options. dateformat format_string Specify the extension for dateext using the notation similar to strftime(3) function. Only %Y %m %d %H and %s specifiers are allowed. The default value is -%Y%m%d except hourly, which uses -%Y%m%d%H as default value. Note that also the character separating log name from the extension is part of the dateformat string. The system clock must be set past Sep 9th 2001 for %s to work correctly. Note that the datestamps generated by this format must be lexically sortable (i.e., first the year, then the month then the day. e.g., 2001/12/01 is ok, but 01/12/2001 is not, since 01/11/2002 would sort lower while it is later). This is because when using the rotate option, logrotate sorts all rotated filenames to find out which logfiles are older and should be removed. dateyesterday Use yesterday's instead of today's date to create the dateext extension, so that the rotated log file has a date in its name that is the same as the timestamps within it. delaycompress Postpone compression of the previous log file to the next rotation cycle. This only has effect when used in combination with compress. It can be used when some program cannot be told to close its logfile and thus might continue writing to the previous log file for some time. extension ext Log files with ext extension can keep it after the rotation. If compression is used, the com‐ pression extension (normally .gz) appears after ext. For example you have a logfile named and want to rotate it to instead of . hourly Log files are rotated every hour. Note that usually logrotate is configured to be run by cron daily. You have to change this configuration and run logrotate hourly to be able to really rotate logs hourly. ifempty Rotate the log file even if it is empty, overriding the notifempty option (ifempty is the default). include file_or_directory Reads the file given as an argument as if it was included inline where the include directive appears. If a directory is given, most of the files in that directory are read in alphabetic order before processing of the including file continues. The only files which are ignored are files which are not regular files (such as directories and named pipes) and files whose names end with one of the taboo extensions, as specified by the tabooext directive. mail address When a log is rotated out of existence, it is mailed to address. If no mail should be generated by a particular log, the nomail directive may be used. mailfirst mailfirst When using the mail command, mail the just-rotated file, instead of the about-to-expire file. maillast When using the mail command, mail the about-to-expire file, instead of the just-rotated file (this is the default). maxage count Remove rotated logs older than
发布者:admin,转转请注明出处:http://www.yc00.com/xiaochengxu/1688383726a129876.html
评论列表(0条)