A while ago i noticed that /var partition on a certain server was almost filled up to a 100% up and started researching what caused this.
I noticed that log files in /var/log directory were not rotating. I decided to run the log rotation manually when i got this error “error: bad top line in state file /var/lib/logrotate.status”.
It was the first time i ever say this error and the fact that the logs stopped rotating was bad news! I needed to fix it asap!
Let’s fix “error: bad top line in state file /var/lib/logrotate.status”!
Since my log files were not rotating i decided to run logrotate manually to see what the problem was. You can run logrotate very simply bi running the logrotate command and pointing to the desired logrotate configuration file.
This is how we run logrotate manually for all logrotate configuration files in /etc/logrotate.d directory:
[root@geekpeek ~]# logrotate /etc/logrotate.d/* error: bad top line in state file /var/lib/logrotate.status error: could not read state file, will not attempt to write into it
Due to the error i got when running logrotate manually, i decided to backup logrotate.status file by moving (renameing) it:
[root@geekpeek ~]# mv /var/lib/logrotate.status /var/lib/logrotate.status.orig
[root@geekpeek ~]# logrotate /etc/logrotate.d/* [root@geekpeek ~]#
[root@geekpeek ~]# ll /var/lib/logrotate.status -rw-r--r-- 1 root root 225 Aug 7 08:16 /var/lib/logrotate.status
[root@geekpeek ~]# logrotate -f /etc/logrotate.d/* [root@geekpeek ~]#