Hi,
Please check the below code...:wall:
if [ `grep -c "/var/log/AAA/BBB" /etc/logrotate.conf` -eq 0 ] ; then
echo "/var/log/AAA/BBB/xxx_*.log /var/log/AAA/BBB/yyy_*.log {" >> /etc/logrotate.conf
echo " weekly" >> /etc/logrotate.conf
echo " rotate 10" >> /etc/logrotate.conf
echo " compress" >> /etc/logrotate.conf
echo " postrotate" >> /etc/logrotate.conf
echo " /usr/bin/killall -HUP syslogd" >> /etc/logrotate.conf
echo " sleep 3" >> /etc/logrotate.conf
echo " mv /var/log/AAA/BBB/xxx_*.gz /var/log/AAA/BBB/xxx_`date +%d%b%y`.log.gz" >> /etc/logrotate.conf
echo " mv /var/log/AAA/BBB/yyy_*.gz /var/log/AAA/BBB/yyy_`date +%d%b%y`.log.gz" >> /etc/logrotate.conf
echo " endscript" >> /etc/logrotate.conf
echo " copytruncate" >> /etc/logrotate.conf
echo "}" >> /etc/logrotate.conf
fi
In this, I am trying to compress and logrotate 2 types of log files in the same folder. Also renaming the files with the current date as a part of them, which denotes the date of rotation. After Postrotate and endscript tags, i am using copytruncate. But in the postrotate tag, I am renaming the file names. So will it effect the copytruncate... or any other directive in the logrotate.conf file...?
Will the previous log files be removed asusual..?
Please help me in this regard...:wall: