Skip to content

Troubleshoot Linux Logs That Won't Rotate

Admin
November 20, 2026
5 min read
Intermediate
💻 Target OS: Ubuntu 26.04 LTS / RHEL 10

Before you begin

  • Applies to:Linux hosts with systemd, logrotate, and an application that writes to a file.
  • Where to start:Use a shell on the host that writes and rotates the log. If rotation is scheduled by systemd, use its timer and service checks.
  • What you need:Have the full log path, rotation configuration and schedule, and service owner's details. Replace the example /var/log/myapp/app.log with the actual path.
Guide tools
Guide tools
0/0 Steps (0%)

Troubleshooting Steps

01

Separate a rotation problem from a logging problem

Start here

Confirm the application writes directly to a file. Journal-only logging is managed by journald. For file logging, record the current and rotated paths, inode numbers, file sizes, and last write times.

Terminal window
sudo ls -li -- /var/log/myapp
sudo stat -- /var/log/myapp/app.log
02

Verify when logrotate actually runs

Check the timer and service logs. A timer being active only means it is scheduled. Confirm the service actually ran and inspect its exit status. If these units are absent, inspect the host’s approved cron or alternate schedule rather than adding a duplicate.

Terminal window
systemctl list-timers --all logrotate.timer
systemctl status logrotate.service --no-pager
sudo journalctl -u logrotate.service --since '7 days ago' --no-pager
03

Preview the effective configuration

Use the same main configuration that the scheduler uses to include global defaults and drop-ins. Debug mode prints decisions and does not rotate logs or update the state file. Look for the exact path and whether it is missing, empty, not due, or rejected.

What you should see · The debug output names the exact log and gives a reason for rotating or skipping it.

If you see something else · If the log is missing from the output, check that the active configuration includes its stanza. For an explicit error, fix that error and repeat debug mode before triggering a rotation.

Terminal window
sudo logrotate --debug /etc/logrotate.conf
04

Check whether the application reopened the new log

If the archive exists but the active file stays unchanged, look for an application process holding the rotated file open. Replace the sample suffix with the real archive name. Compare the expected service account and file ownership with the service’s supported reopen behavior.

Terminal window
sudo lsof -- /var/log/myapp/app.log /var/log/myapp/app.log.1
05

Correct the cause and check again

Restore the approved schedule if missing. For configuration errors, correct the identified path, ownership, or rule and rerun debug mode. When rename-and-create rotation succeeds but the process keeps writing to the old inode, use the vendor-supported reopen or reload mechanism. Avoid switching to copytruncate without reviewing its possible log-loss window.

06

Verify on the next approved rotation

Check the scheduler result and archive. Trigger an ordinary approved request and confirm new entries reach the active file and any collector. If the change breaks writes or forwarding, restore the previous approved configuration and use the application’s supported recovery procedure.

Decide What to Do Next

FindingNext action
Debug reports the log is not dueCheck the time or size rule against the actual schedule.
Service reports an errorReview that invocation’s message, including configuration and directory permissions.
Archive grows while active file stays quietCheck the service’s open descriptors and reopen behavior.

References

Comments