hi,
How to logrotate irrespective of the size of a file/directory...?
Please help me in this regard...
I hope I'm not the only one that is going to say this but WHAT? Could you give examples of what you are wanting to do? Do you have any code to share that we could help you with? I don't know if it's just me but your request seems convoluted and extremely unclear. Please give examples.
Hi, Please check the below example,
if [ `grep -c "/var/log/XXX " /etc/logrotate.conf` -eq 0 ] ; then
echo "/var/log/XXX/*.log "{" >> /etc/logrotate.conf
echo " rotate 10" >> /etc/logrotate.conf
echo " size 5M" >> /etc/logrotate.conf
echo " postrotate" >> /etc/logrotate.conf
echo " /usr/bin/killall -HUP syslogd" >> /etc/logrotate.conf
echo " endscript" >> /etc/logrotate.conf
echo " compress" >> /etc/logrotate.conf
echo " copytruncate" >> /etc/logrotate.conf
echo "}" >> /etc/logrotate.conf
fi
But what I required is, as my log file never reaches the max size of 5M and it will be max upto 5-10K(which is also not sure), I would like to logrotate it monthly, irrespective of the size whether it reached some specified size. And also I have to zip all the log files while rotation.
You can do something similar to following,
this is from the logrotate man page:
# sample logrotate configuration file
compress
/var/log/messages {
rotate 5
weekly
postrotate
/sbin/killall -HUP syslogd
endscript
}
What my doubt is, irrespective of the size means, can I ignore using the directive "size" in the code..??