linux - How to force (or workaround) logrotate to move old logs to olddir on different physical disk? -
i want logrotate
copy , truncate log file , use olddir on different physical disk. according manual, olddir can't on different physical disk because default behaviour of logrotate rename original log file, wouldn't possible different physical disk.
well, using copytruncate
directive, makes copy of original file , truncates original file. there shouldn't problem moving newly copied file different location on different physical disk.
but when run logrotate, still complains logfile , olddir beeing on different devices.
is there way around ? possibly running custom postrotate script move log files desired location ?
this logrotate man page.
olddir directory <br> logs moved directory rotation. **the directory must on same physical device log file being rotated**, , assumed relative directory holding log file unless absolute path name specified. when option used old versions of log end in directory. option may overridden noolddir option.
existence of olddir
on same physical device limitation.
one can use below workaround.
set olddir
directory in same physical disk, , use postrotate
script move contents of olddir
directory on different physical device.
example logrotate configuration file:
/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 }
Comments
Post a Comment