0

/usr/sbin/logrotate is used to log rotate syslog-NG logging, as shown below:

[root@machine1 output]# crontab -l
# 00 23 * * * /TSM/bkup 1>/dev/null 2>&1
1 * * * * /usr/sbin/logrotate /app/syslog-ng/custom/conf/syslog-ng-rotate.conf
[root@machine1 output]#
[root@machine1 output]# pwd
/app/syslog-ng/custom/output
[root@machine1 output]# ls -l
total 4
-rw------- 1 root root 142 Oct  3 16:08 all_devices.log
[root@machine1 output]#
[root@machine1 output]#
[root@machine1 output]# date
Wed Oct 10 11:26:54 EDT 2018
[root@machine1 output]#
[root@machine1 output]#
[root@machine1 output]# cat /app/syslog-ng/custom/conf/syslog-ng-rotate.conf
/app/syslog-ng/custom/output/all_devices.log {
copytruncate
dateext
rotate 365
daily
sharedscripts
compress
postrotate
      /app/syslog-ng/sbin/syslog-ng-ctl reload
endscript
}
[root@machine1 output]#
[root@machine1 output]#
[root@machine1 output]# date
Wed Oct 10 11:29:51 EDT 2018
[root@machine1 output]#
[root@machine1 output]#
[root@machine1 output]# ls -l
total 4
-rw------- 1 root root 142 Oct  3 16:08 all_devices.log
[root@machine1 output]# /usr/sbin/logrotate /app/syslog-ng/custom/conf/syslog-ng-rotate.conf
[root@machine1 output]# ls -l
total 4
-rw------- 1 root root 142 Oct  3 16:08 all_devices.log
[root@machine1 output]# 
[root@machine1 output]#
[root@machine1 output]# cat /etc/logrotate.conf
# see "man logrotate" for details
# rotate log files weekly
weekly

# keep 4 weeks worth of backlogs
rotate 4

# create new (empty) log files after rotating old ones
create

# use date as a suffix of the rotated file
dateext

# uncomment this if you want your log files compressed
#compress

# RPM packages drop log rotation information into this directory
include /etc/logrotate.d

# no packages own wtmp and btmp -- we'll rotate them here
/var/log/wtmp {
    monthly
    create 0664 root utmp
        minsize 1M
    rotate 1
}

/var/log/btmp {
    missingok
    monthly
    create 0600 root utmp
    rotate 1
}

# system-specific logs may be also be configured here.
[root@machine1 output]#
[root@machine1 output]#

But, I do not see compressed file getting generated in ../output folder, every minute(crontab).

why logrotate does not generate compressed file??

  • the config days daily...? – Jeff Schaller Oct 10 '18 at 15:52
  • run it manually with logrotate --debug /app/.../conf and it'll probably show "does not need rotating" – Jeff Schaller Oct 10 '18 at 16:02
  • @JeffSchaller Do I need to remove entry daily? to make logrotate work manually anytime? It does not rotate on removing entry daily... – overexchange Oct 10 '18 at 16:42
  • What is the linux that you are using ? – sai sasanka Oct 11 '18 at 6:08
  • Take a look this answer: unix.stackexchange.com/questions/15546/… – sai sasanka Oct 11 '18 at 6:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.