Friday 9 October 2020

Logrotate with compress and delaycompress options.

Step1:-

[root@sankar ~]#  cat /etc/logrotate.d/sankar_myapp

/var/hvmail/log/myapp_event-processor/logfile.log {
    su root root
    rotate 7
    hourly
    compress
    delaycompress
}
[root@sankar ~]# 


Step2:- Dry run (-d) option

[root@sankar ~]# logrotate -d /etc/logrotate.d/sankar_myapp
...
....


Step3:- 
with the exception of the most recent one, should be compressed.


[root@sankar ~]# cd /var/hvmail/log/myapp_event-processor/ 

[root@sankar  myapp_event-processor]# ls -ltrh
total 28M
-rw-rwxr-x 1  root          root   23K Oct  9 09:03 logfile.log.2.gz
-rw-rwxr-x 1 root           root      421K Oct  9 10:06 logfile.log.1
-rw-rwxr-x 1 root           root      427K Oct  9 10:59 logfile.log