Log Rotation

/etc/logrotate.conf

/var/log/dovecot.info.log {
        dateext
        size 51200k
        compress
        mail username _AT_ mydomain _DOT_ gr
        
        prerotate
                /etc/init.d/dovecot stop
        endscript
        postrotate
                /etc/init.d/dovecot start
        endscript
}


# logrotate -d -f -v /etc/logrotate.conf

dnsdist.log


/etc/logrotate.d/dnsdist

/var/log/dnsdist.log {
    rotate 7
    daily
    dateext
    delaycompress
    compress
    postrotate
        [ ! -f /var/run/dnsdist.pid ] || kill -USR1 `cat /var/run/dnsdist.pid`
    endscript
}




# logrotate -d -f -v /etc/logrotate.d/dnsdist


reading config file /etc/logrotate.d/dnsdist
reading config info for /var/log/dnsdist.log 

Handling 1 logs

rotating pattern: /var/log/dnsdist.log  forced from command line (no old logs will be kept)
empty log files are rotated, old logs are removed
considering log /var/log/dnsdist.log
  log needs rotating
rotating log /var/log/dnsdist.log, log->rotateCount is 0
dateext suffix '-20170812'
glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
glob finding logs to compress failed
glob finding old rotated logs failed
fscreate context set to unconfined_u:object_r:var_log_t:s0
renaming /var/log/dnsdist.log to /var/log/dnsdist.log-20170812
disposeName will be /var/log/dnsdist.log-20170812.gz
running postrotate script
running script with arg /var/log/dnsdist.log: "
        /bin/kill -USR1 14769 2> /dev/null || true
"
removing old log /var/log/dnsdist.log-20170812.gz
error: error opening /var/log/dnsdist.log-20170812.gz: No such file or directory



# ls -Zltr dnsdist.log*

-rw-r--r--. 1 unconfined_u:object_r:var_log_t:s0 root root 233768249 Aug 12 20:42 dnsdist.log-20170812
-rw-r--r--. 1 system_u:object_r:var_log_t:s0   root root      8905 Aug 12 20:56 dnsdist.log