logrotate fails to run, if status file is corrupt (logrotate running during reboot?)
Bug #1385464 reported by
Daniel Holbach
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Canonical System Image |
Fix Released
|
High
|
Unassigned | ||
upstart (Ubuntu) |
Fix Released
|
Undecided
|
Unassigned | ||
upstart (Ubuntu RTM) |
Fix Released
|
Undecided
|
Ricardo Salveti |
Bug Description
phablet@
654M /var/log/syslog
phablet@
error: bad top line in state file /var/lib/
phablet@
/opt/click.
tags: | added: rtm14 |
tags: | added: touch-2014-10-30 |
Changed in canonical-devices-system-image: | |
importance: | Undecided → High |
milestone: | none → ww05-2015 |
status: | New → Confirmed |
affects: | logrotate (Ubuntu) → upstart (Ubuntu) |
Changed in upstart (Ubuntu): | |
status: | New → Fix Released |
affects: | logrotate (Ubuntu RTM) → upstart (Ubuntu RTM) |
Changed in canonical-devices-system-image: | |
status: | Confirmed → Fix Released |
To post a comment you must log in.
To be clear, this issue was observed on Touch.
Interestingly, we already have a fix for this, but it hasn't landed in the archive or on Tocuh; the upstart session init has a logrotate job (/usr/share/ upstart/ sessions/ logrotate. conf) which is used to rotate the users session init log files. I'd noticed the corruption issue and put a fix in the tip of lp:ubuntu/upstart. Essentially, the solution is to remove the status file as it will be regenerated on next logrotate run. However, if the status file is corrupt, logrotate will never rewrite it and as such, no logrotation occurs leading to unlimited logfile growth.
Here's the fix from the upstart job:
__________
# Sometimes the state file can become corrupt (probably caused by
# logrotate updating it on shutdown). In these cases the file ends in
# nul bytes which causes a subsequent logrotate run (even a forced run)
# to refuse to process it meaning no files get rotated.
#
# Hence, if nul bytes are detected, reset the state file to allow logrotate
# to work.
[ -e "$statefile" ] && egrep '[^[:print:]]' "$statefile" && rm "$statefile"
__________