Logrotate Successful, original file goes back to original size
        Posted  
        
            by 
                drewrockshard
            
        on Server Fault
        
        See other posts from Server Fault
        
            or by drewrockshard
        
        
        
        Published on 2011-01-11T23:43:52Z
        Indexed on 
            2011/01/11
            23:54 UTC
        
        
        Read the original article
        Hit count: 447
        
Has anyone had any issues with logrotate before that causes a log file to get rotated and then go back to the same size it originally was? Here's my findings:
Logrotate Script:
/var/log/mylogfile.log {
    rotate 7
    daily
    compress
    olddir /log_archives
    missingok
    notifempty
    copytruncate
}
Verbose Output of Logrotate:
copying /var/log/mylogfile.log to /log_archives/mylogfile.log.1 truncating /var/log/mylogfile.log compressing log with: /bin/gzip removing old log /log_archives/mylogfile.log.8.gz
Log file after truncate happens
[root@server ~]# ls -lh /var/log/mylogfile.log -rw-rw-r-- 1 part1 part1 0 Jan 11 17:32 /var/log/mylogfile.log
Literally Seconds Later:
[root@server ~]# ls -lh /var/log/mylogfile.log -rw-rw-r-- 1 part1 part1 3.5G Jan 11 17:32 /var/log/mylogfile.log
RHEL Version:
[root@server ~]# cat /etc/redhat-release Red Hat Enterprise Linux ES release 4 (Nahant Update 4)
Logrotate Version:
[root@DAA21529WWW370 ~]# rpm -qa | grep logrotate logrotate-3.7.1-10.RHEL4
Few Notes:
- Service can't be restarted on the fly, so that's why I'm using copytruncate
 - Logs are rotating every night, according to the 
olddirdirectory having log files in it from each night. 
© Server Fault or respective owner