I am configuring log rotation one of my production server. I am having a weired issue. I have configured the log rotation for a file on daily basis.

But unfortunately the rotation is not working. I have checked the status of the "/var/lib/logrotate/logrotate.status", It says the file has been rotated successfully. But it is not

cat /var/lib/logrotate/logrotate.status
logrotate state -- version 2
"/var/log/yum.log" 2019-1-4-14:0:0
"/var/log/chef/client.log" 2019-4-14-3:33:2
"/var/log/boot.log" 2019-1-10-3:46:1
"/usr/local/rms/kafka/kafka-connect-fluentd/stdout.log" 2019-4-15-3:9:1
"/var/log/chrony/*.log" 2019-1-4-14:0:0
"/var/log/wtmp" 2019-1-4-14:0:0
"/var/log/spooler" 2019-4-14-3:33:2
"/var/log/btmp" 2019-1-4-14:0:0
"/var/log/telegraf/telegraf.log" 2019-1-10-3:0:0

The file want to rotate is: /usr/local/rms/kafka/kafka-connect-fluentd/stdout.log

Log-rotate config file :

/usr/local/rms/kafka/kafka-connect-fluentd/stdout.log {
    rotate 7
       /bin/kill -HUP `cat /usr/local/rms/kafka/kafka-connect-fluentd/connector.pid 2> /dev/null` 2> /dev/null || true

  • 2
    Please provide the logrotate configuration for that file as well – Gerald Schneider Apr 15 at 10:06
  • Check your logrotate config, if you are rotating based on size then I guess logrotate doesn't adjust the file if the size threshold isn't breached. – kn330 Apr 15 at 10:13
  • @GeraldSchneider & @kn330 Thank you sir. Rotation is not based on the size.Please find my log rotation configs file /usr/local/rms/kafka/kafka-connect-fluentd/stdout.log { daily copytruncate rotate 7 compress postrotate /bin/kill -HUP cat /usr/local/rms/kafka/kafka-connect-fluentd/connector.pid 2> /dev/null 2> /dev/null || true endscript } – UtpMahesh Apr 15 at 12:21
  • Please don't add more information as a comment, edit your question instead. It is very hard to read as a comment. – Gerald Schneider Apr 15 at 12:32
  • @GeraldSchneider , sorry, I updated on the description. – UtpMahesh Apr 15 at 12:47

try with my logrotate file: This rotates the logs of apache with the date, and if it ends in 2019 it compresses those files before deleting them.

/var/log/apache2/*.log {
        create 0640 root root
        su root adm
        rotate 2
        dateformat -%d-%m-%Y.log

        gzip /var/log/apache2/*-2019.log
        service apache2 restart
        rm /var/log/apache2/*.gz

If you want to check or force the execution of a logrotate execute the following command:

logrotate -vf /etc/logrotate.d/name_of_your_file

and with the verbose mode, you will be able to see what is happening there

Hope this be helpful.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.