wuzhidefeng 2018-03-01 03:20 采纳率: 0%
浏览 1121
已结题

使用logrotate备份不报错,但失败

使用redhat系统logrotate测试备份文件,测试的文件为/var/log/test.log。
在/etc/logrotate.d目录下新建文件qztest2,内容如下:
/var/log/test.log{
rotate 10
daily
nocompress
sharedscripts
postrotate
/bin/kill -HUP cat /var/run/syslogd.pid 2> /dev/null 2> /dev/null || true
endscript
}
使用命令logrotate -fd /etc/logrotate.d/qztest2,响应如下:
reading config file /etc/logrotate.d/qztest2
reading config info for /var/log/test.log

Handling 1 logs

rotating pattern: /var/log/test.log forced from command line (10 rotations)
empty log files are rotated, old logs are removed
considering log /var/log/test.log
log needs rotating
rotating log /var/log/test.log
renaming /var/log/test.log.10 to /var/log/test.log.11 (rotatecount 10, logstart 1, i 10),
renaming /var/log/test.log.9 to /var/log/test.log.10 (rotatecount 10, logstart 1, i 9),
renaming /var/log/test.log.8 to /var/log/test.log.9 (rotatecount 10, logstart 1, i 8),
renaming /var/log/test.log.7 to /var/log/test.log.8 (rotatecount 10, logstart 1, i 7),
renaming /var/log/test.log.6 to /var/log/test.log.7 (rotatecount 10, logstart 1, i 6),
renaming /var/log/test.log.5 to /var/log/test.log.6 (rotatecount 10, logstart 1, i 5),
renaming /var/log/test.log.4 to /var/log/test.log.5 (rotatecount 10, logstart 1, i 4),
renaming /var/log/test.log.3 to /var/log/test.log.4 (rotatecount 10, logstart 1, i 3),
renaming /var/log/test.log.2 to /var/log/test.log.3 (rotatecount 10, logstart 1, i 2),
renaming /var/log/test.log.1 to /var/log/test.log.2 (rotatecount 10, logstart 1, i 1),
renaming /var/log/test.log.0 to /var/log/test.log.1 (rotatecount 10, logstart 1, i 0),
renaming /var/log/test.log to /var/log/test.log.1
removing old log /var/log/test.log.11
running shared postrotate script
running script with arg /var/log/test.log: "
/bin/kill -HUP cat /var/run/syslogd.pid 2> /dev/null 2> /dev/null || true
"
但是实际上最终并没有生成test.log.1文件。求问?

  • 写回答

2条回答 默认 最新

  • antimoth 2018-03-01 03:39
    关注

    log下建test.log这个文件了吗?没有对应的文件貌似不会执行的。

    评论

报告相同问题?

悬赏问题

  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 matlab求解平差
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊
  • ¥15 安装svn网络有问题怎么办