linux在日志页复制,linux – 如何强制(或解决)logrotate将旧日志移动到不同物理磁盘上的olddir?...

这是来自logrotate手册页.

olddir directory

Logs are moved into directory for rotation. **The directory must be on the

same physical device as the log file being rotated**, and is assumed to be

relative to the directory holding the log file unless an absolute path

name is specified. When this option is used all old versions of the log

end up in directory. This option may be overridden by the noolddir

option.

olddir在同一物理设备上的存在是有限的.

可以使用以下解决方法.

将olddir设置为同一物理磁盘中的目录,并使用postrotate脚本将olddir的内容移动到不同物理设备上的目录.

示例logrotate配置文件:

/var/log/httpd/*log {

copytruncate

olddir /var/log/httpd/olddir

rotate 5

missingok

notifempty

sharedscripts

delaycompress

postrotate

mv /var/log/httpd/olddir/* /vagrant/httpd/olddir/

/sbin/service httpd reload > /dev/null 2>/dev/null || true

endscript

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值