openclaw - 💡(How to fix) Fix Log rotation cron job checks wrong file — journald is the real storage pressure [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#74801Fetched 2026-05-01 05:41:14
View on GitHub
Comments
1
Participants
2
Timeline
2
Reactions
2
Timeline (top)
commented ×1cross-referenced ×1

Root Cause

When OpenClaw runs as a systemd user service, openclaw.log stays near-empty because the file transport is never initialized. All actual log output goes to journald, which has no size cap and grows unbounded.

RAW_BUFFERClick to expand / collapse

Bug

The built-in log rotation cron job (checks ~/.openclaw/logs/openclaw.log for 50 MB) is watching the wrong file.

When OpenClaw runs as a systemd user service, openclaw.log stays near-empty because the file transport is never initialized. All actual log output goes to journald, which has no size cap and grows unbounded.

On our install, journald is already at 152 MB with no ceiling.

Current behavior

  • Cron job monitors ~/.openclaw/logs/openclaw.log (786 KB on our system)
  • Threshold set at 50 MB — will never trigger
  • journald accumulates all real logs indefinitely

Expected behavior

Either:

  1. Rotation job should also vacuum journald (journalctl --vacuum-size= / --vacuum-time=), or
  2. Docs/setup should recommend setting SystemMaxUse= in /etc/systemd/journald.conf when running as a systemd service, or
  3. The gateway should initialize the file log transport when running under systemd so openclaw.log actually receives output

Additional notes

  • There is already a rotate_openclaw_log.py script with copy-truncate + gzip archive semantics, but the cron job doesn't call it — it truncates to empty directly, losing log history
  • The cron job threshold (50 MB) doesn't match the script default (10 MB)

Environment

  • OS: Linux (systemd user service)
  • Log path: ~/.openclaw/logs/openclaw.log
  • Service: openclaw-gateway.service (user unit)

extent analysis

TL;DR

The log rotation cron job should be modified to also consider journald logs or an alternative solution should be implemented to prevent unbounded log growth.

Guidance

  • Modify the cron job to use journalctl --vacuum-size= to rotate journald logs, ensuring a size cap is enforced.
  • Consider setting SystemMaxUse= in /etc/systemd/journald.conf to limit journald log size when running as a systemd service.
  • Update the rotate_openclaw_log.py script to handle log rotation for both file and journald logs, and adjust the cron job to call this script instead of direct truncation.
  • Review and align the log rotation threshold (50 MB) with the script default (10 MB) for consistency.

Example

import subprocess

# Example of using journalctl to vacuum logs based on size
def vacuum_journald(size_mb):
    subprocess.run(f"journalctl --vacuum-size={size_mb}M", shell=True)

# Call the function with the desired size limit
vacuum_journald(50)

Notes

The chosen solution depends on the specific requirements and constraints of the OpenClaw setup and the Linux environment it's running in. Ensuring log history is preserved and easily accessible is crucial.

Recommendation

Apply a workaround by modifying the cron job to handle journald log rotation, as this directly addresses the issue of unbounded log growth without requiring changes to the underlying logging configuration.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

Either:

  1. Rotation job should also vacuum journald (journalctl --vacuum-size= / --vacuum-time=), or
  2. Docs/setup should recommend setting SystemMaxUse= in /etc/systemd/journald.conf when running as a systemd service, or
  3. The gateway should initialize the file log transport when running under systemd so openclaw.log actually receives output

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix Log rotation cron job checks wrong file — journald is the real storage pressure [1 comments, 2 participants]