karthi_ms
karthi_ms

Reputation: 5698

Reason for corrupted /var/lib/logrotate/status

I'm using logrotate 3.7.1 to rotate my logs.Recently I found that the logrotate getting failed and the reason was /var/lib/logrotate/status file getting corrupted.I have cleared the log file and run the logrotate and it worked correctly.

I want to know for what reason the file getting corrupted.

Thanks in advance.

Upvotes: 0

Views: 2885

Answers (4)

tonywl
tonywl

Reputation: 131

If somehow there are multiple concurrent running logrotate, the status file could easily get corrupted, this is true when there are multiple uses of logrotate and some are configured with cron job directly (instead of adding configure entry to /etc/logrotate.d) or logrotate gets run manually.

Upvotes: 0

Josip Rodin
Josip Rodin

Reputation: 809

You have to post the specific error message from logrotate when parsing the corrupted status file, as it indicates the line number in the file that corrupted it.

In my case, for example, it was invalid UTF-8 byte sequences in filename patterns being processed; the root cause wasn't in logrotate but in the programs that had created those logs.

Upvotes: 0

Danny
Danny

Reputation: 39

in general file corruption on Unix variants operating system can happen for several reasons. Material defect on disk which often leave indication in syslog is one. kill -9 on a process currently re-writing the file for files greater than OS native block size. Violent and unexpected power loss which might lead in some hardware arrangement to abrupt shutdown. No space on disk incident which is not very well tolerated by utility. A second or more copy’s of utility running where proper locking mechanism was not included or deemed necessary for the file in question. I will recommend using “/usr/sbin/logrotate -dv /etc/logrotate.conf” on boot to detect, fix and log such incident on 24/7 setups.

Upvotes: 1

thkala
thkala

Reputation: 86443

(You are not providing the most crucial piece of information, i.e. what exactly you mean by "failed" and "corrupted". Without that information I can only take a shot in the dark...)

logrotate should be able to rotate any file, regardless of their contents - as far as I know all it does is rename and compress the file. A file with corrupt contents would be processed just the same as any other file.

With that in mind, I can only think that the cause of the logrotate failure is what caused the log file corruption in the first place. I'd start by having a closer look at your storage hardware - e.g. a disk failure could corrupt a log file and then cause an I/O error when it is read, thus stopping logrotate in its tracks.

Upvotes: 1

Related Questions