i created my logrotate in /etc/logrotate.d/rsyslog
/var/log/pcapcapture/capture.log
{
maxsize 100k
minsize 100k
hourly
rotate 7
postrotate
service rsyslog rotate > /dev/null
endscript
}
运行后,我可以看到当我执行命令 sudo logrotate -d /etc/logrotate.conf
considering log /var/log/pcapcapture/capture.log
log needs rotating
rotating log /var/log/pcapcapture/capture.log, log->rotateCount is 7
dateext suffix '-2018060617'
glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
renaming /var/log/pcapcapture/capture.log.7 to /var/log/pcapcapture/capture.log.8 (rotatecount 7, logstart 1, i 7),
renaming /var/log/pcapcapture/capture.log.6 to /var/log/pcapcapture/capture.log.7 (rotatecount 7, logstart 1, i 6),
renaming /var/log/pcapcapture/capture.log.5 to /var/log/pcapcapture/capture.log.6 (rotatecount 7, logstart 1, i 5),
renaming /var/log/pcapcapture/capture.log.4 to /var/log/pcapcapture/capture.log.5 (rotatecount 7, logstart 1, i 4),
renaming /var/log/pcapcapture/capture.log.3 to /var/log/pcapcapture/capture.log.4 (rotatecount 7, logstart 1, i 3),
renaming /var/log/pcapcapture/capture.log.2 to /var/log/pcapcapture/capture.log.3 (rotatecount 7, logstart 1, i 2),
renaming /var/log/pcapcapture/capture.log.1 to /var/log/pcapcapture/capture.log.2 (rotatecount 7, logstart 1, i 1),
renaming /var/log/pcapcapture/capture.log.0 to /var/log/pcapcapture/capture.log.1 (rotatecount 7, logstart 1, i 0),
renaming /var/log/pcapcapture/capture.log to /var/log/pcapcapture/capture.log.1
creating new /var/log/pcapcapture/capture.log mode = 0644 uid = 0 gid = 0
running postrotate script
running script with arg /var/log/pcapcapture/capture.log: "
service rsyslog rotate > /dev/null
"
removing old log /var/log/pcapcapture/capture.log.8
error: error opening /var/log/pcapcapture/capture.log.8: No such file or directory
switching euid to 0 and egid to 0
但为什么我无法在目录中查看,有人能帮助我吗
从评论中移出,以便输出可以被格式化:
/bin/ls -ld /var/log
drwxrwxr-x 15 root syslog 4096 Jun 7 10:17 /var/log
/usr/bin/id uid=1000(alethea) gid=1000(alethea),groups=1000(alethea),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),113(lpadmin),128(sambashare),130(wireshark)