1.create:create mode 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.
以下面这个为例:
$ cat /etc/logrotate.conf
/var/log/test.log {
size 1M
create 666 jaseywang jaseywang
}
$ sudo logrotate /etc/logrotate.conf
可以通过下面这个实验来验证,开三个窗口,分别执行:
# while true;do cat /dev/zero > /var/log/test.log ;done
# logrotate /etc/logrotate.conf
# ll /var/log/test.log*
也就是说 logrotate 之后生成的 file.log 新文件的权限,用户,用户组,执行了 logrotate 之后,该日志文件对应的服务会向 test.log.1 文件继续写入而不是向 test.log 写入。
Continue reading →