这是我每天用来压缩日志文件的日志文件。
/home/ubuntu/logs/server.log {
daily
missingok
rotate 1
compress
create
dateext
dateyesterday
dateformat .%Y-%m-%d
extension .gz
postrotate
mv /home/ubuntu/logs/*.gz /home/ubuntu/zip/
endscript
}
当我使用该--force
选项运行时,我看不到压缩文件。我只能看到应用于文件的日期扩展名。以下是运行该命令的结果
logrotate /home/ubuntu/conf/logrotate.conf --state /home/ubuntu/conf/logrotate.state --verbose --force
结果:
rotating pattern: /home/ubuntu/logs/server.log forced from command line (1 rotations)
empty log files are rotated, old logs are removed
considering log /home/ubuntu/logs/server.log
log needs rotating
rotating log /home/ubuntu/logs/server.log, log->rotateCount is 1
Converted ' .%Y-%m-%d' -> '.%Y-%m-%d'
dateext suffix '.2018-03-04'
glob pattern '.[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]'
glob finding old rotated logs failed
renaming /home/ubuntu/logs/server.log to /home/ubuntu/logs/server.log.2018-03-04
creating new /home/ubuntu/logs/server.log mode = 0664 uid = 1000 gid = 1000
running postrotate script
mv: cannot stat '/home/ubuntu/logs/*.gz': No such file or directory
error: error running non-shared postrotate script for /home/ubuntu/logs/server.log of '/home/ubuntu/logs/server.log '
我如何确保昨天创建的日志文件被压缩,并且为今天创建一个新的空日志文件?