Skip to content

VPS

Keeping Linux Logs Useful Without Filling the Disk

Separate journal, application and container logs, then choose retention that supports diagnosis and recovery.

LogsJournalRetention
Reading time
2 min read
Published
Updated
Maintained by
EnderHost Team

Set log retention for each system that writes logs. The system journal, application files and container logging can have separate limits. Reducing one does not necessarily stop another from filling the disk.

Measure before choosing a limit

journalctl --disk-usage
sudo journalctl -u example.service --since "1 hour ago" --no-pager

The first command reports journal storage. The second inspects one service over a recent interval; replace the example name. Look for repeated errors that explain rapid growth. Fixing a tight error loop is more useful than continually deleting its output.

Choose size and time requirements

systemd-journald supports storage and retention settings, including size controls for persistent and runtime journals. Review the manual for your installed version and use a configuration drop-in rather than silently replacing distribution defaults. Decide whether logs must survive a reboot.

Retention questions
QuestionReason
How quickly is an incident noticed?Logs need to cover the investigation interval
How fast does the service write?A size limit can remove history before a time limit
Do logs contain personal data or secrets?Access and collection should be limited
Is off-host evidence needed?Local logs disappear with the machine
How are application files rotated?Applications may need to reopen their output

Verify rotation in the actual application

  1. Save logs needed for an active incident before cleanup.
  2. Set the supported retention mechanism for each log source.
  3. Confirm that the application continues writing after rotation.
  4. Check that new entries are timestamped and attributable to the right service.
  5. Monitor disk growth and confirm the retained history meets your requirement.

Avoid indiscriminate truncation or deletion of files still in use. It can remove evidence without solving the producer problem. Scrub tokens from application output at the source rather than relying on short retention to protect them.

Use disk-full diagnostics to locate the actual growth and monitoring to alert before the next capacity incident.

Sources and references

Hosting documentation. Publication and update dates reflect this edition.

Related articles

Related topics

Hardware we trust. Software you know.

PREPARING YOUR EXPERIENCE