How-To Guides5 min read

How to Troubleshoot Failed Services and Bloated Logs with journalctl and systemd

Step-by-step Linux troubleshooting with systemctl and journalctl across Ubuntu, Debian, Fedora, and Arch: isolate failed services, inspect previous boots, catch short-lived PIDs, and cap journal size safely.

Start service triage with systemctl --failed and journalctl -u unit.service -b -p err..alert. If a short-lived process exits before unit metadata attaches, query by _PID from systemctl status. To reclaim disk space safely, pair journalctl --rotate with --vacuum-size=200M, then set SystemMaxUse in /etc/systemd/journald.conf.d/ rather than deleting files with rm.

Key takeaways

  • Always inspect logs before resetting failed unit state or restarting services.
  • Use persistent /var/log/journal storage with a bounded SystemMaxUse drop-in so crash boots stay debuggable without filling root.
  • Prefer journalctl native flags (-u, -b, -p, --since, --grep) over shell piping.

Quick facts

  • Clearing a failed unit with systemctl reset-failed can unload it and hide recent status output.
  • journalctl --vacuum-size and --vacuum-time only delete archived journal files unless combined with --rotate.
  • Default persistent journal storage uses up to 10 percent of the underlying filesystem, soft-capped at 4 GiB.
  • Adding --grep to journalctl filters inside the binary index faster than piping full output to grep.
  • Regular users need membership in systemd-journal, adm, or wheel (or sudo) to read full system logs.

When a Linux host drops off a load balancer or runs low on disk space under /var, systemctl and journalctl are almost always the fastest path to the actual answer. Across years of debugging production Linux nodes, the biggest mistake I see people make is reaching for systemctl restart or rm -rf /var/log/journal/* before reading the binary journal. Restarting wipes transient clues, and deleting active journal files out from under systemd-journald leaves file descriptors open or corrupts your audit trail.

These steps apply to any modern systemd distribution, including Ubuntu 24.04/26.04 LTS, Debian 12/13, Fedora, RHEL/Alma/Rocky, and Arch Linux.

systemd-journald Troubleshooting and Log Vacuuming Pipeline
systemd-journald Troubleshooting and Log Vacuuming Pipeline

Diagram: Original SVG schematic by Ajay Kumar Chaturvedi.

Prerequisites and Safety Checks

Confirm these basics before inspecting or pruning logs:

  • Shell access with sudo (or membership in the adm group on Ubuntu/Debian, wheel on Fedora/RHEL, or systemd-journal on Arch).
  • Read-only triage comes first; do not restart units or trim logs until you capture any error lines needed for an incident report.
Backup and Data-Loss Warning: Pruning journal logs with --vacuum-size or --vacuum-time permanently deletes archived binary log files. If you are investigating a crash or security event, copy or export the relevant journal slice (journalctl -b -1 > /tmp/prev-boot.log) before rotating and vacuuming.

Step-by-Step Procedure

Step 1: Identify Failed Units Without Clearing State

Target OS: All systemd distributions (Ubuntu, Debian, Fedora, Arch).

List every unit currently in a failed state across the system:

BASH
systemctl --failed

If you suspect a user-level background job (for example a rootless container service or desktop daemon), check the per-user service manager as your normal user:

BASH
systemctl --user --failed

Inspect the unit's current metadata, exit code, and trailing log lines:

BASH
systemctl status <unit>.service --no-pager

As the ArchWiki Systemd guide notes, avoid running systemctl reset-failed until you finish debugging, because resetting can unload the unit depending on CollectMode and make systemctl status stop showing its failure context.

Step 2: Filter Unit Logs by Boot, Priority, and Pattern

Target OS: All systemd distributions (Ubuntu, Debian, Fedora, Arch).

Instead of scrolling through thousands of info lines, filter directly in journalctl by unit, current boot (-b), and syslog priority (err through alert, or 0..3):

BASH
sudo journalctl -u <unit>.service -b -p err..alert --no-pager

For user services, use --user-unit instead of -u. When you need context right before a crash, constrain by relative time and native regex filtering via --grep rather than piping to external grep:

BASH
sudo journalctl -u <unit>.service --since "30 min ago" --grep="timeout|denied"

According to the ArchWiki Journal guide, native --grep avoids formatting lines that do not match, which is noticeably faster on multi-gigabyte journals.

Step 3: Catch Logs for Short-Lived Processes and Previous Boots

Target OS: All systemd distributions (Ubuntu, Debian, Fedora, Arch).

Two common edge cases make beginners think journalctl lost their logs:

  • Short-lived processes: If a service crashes milliseconds after launch, systemd-journald reads /proc metadata asynchronously and may fail to attach _SYSTEMD_UNIT before the PID disappears. Grab the Main PID number from systemctl status <unit>.service and query the kernel PID field directly:
BASH
sudo journalctl -b _PID=<pid>
  • Previous crashed boot: If the host rebooted or panicked, query the previous boot with -b -1 (or list recorded boots with journalctl --list-boots):
BASH
sudo journalctl -b -1 -p err..alert

If --list-boots shows only the current boot, the distro's Storage= mode is likely auto without /var/log/journal created (volatile logs in /run/log/journal vanish on reboot). Ubuntu, Fedora, and Arch enable persistent storage by default, whereas minimal Debian images sometimes omit /var/log/journal unless configured.

Step 4: Check Journal Disk Usage and Trim Safely

Target OS: All systemd distributions (Ubuntu, Debian, Fedora, Arch).

Before pruning logs, measure how much disk space the binary journal currently occupies:

BASH
journalctl --disk-usage

Per the `journalctl(1)` manual page, --vacuum-size= and --vacuum-time= only operate on archived journal files, never the active system.journal currently open for writing. Running vacuum alone often leaves gigabytes untouched until you rotate first.

Back up any crash logs you still need, then rotate and trim in one atomic command:

BASH
sudo journalctl --rotate --vacuum-size=200M

Alternatively, prune archived journals older than two weeks:

BASH
sudo journalctl --rotate --vacuum-time=2weeks

I would skip --vacuum-files= unless you specifically want a fixed file count, because individual journal files vary in size up to SystemMaxFileSize. Bounding by total bytes (--vacuum-size=200M) is far more predictable on small root partitions.

Step 5: Set a Permanent Journal Size Cap with a Drop-In File

Target OS: All systemd distributions (Ubuntu, Debian, Fedora, Arch).

By default, the `journald.conf(5)` manual caps persistent logs at 10 percent of the underlying filesystem (soft-capped at 4 GiB) and tries to leave 15 percent free (SystemKeepFree=). On a 200 GiB server volume, 4 GiB of old logs can still crowd out /var alerts.

Rather than editing /etc/systemd/journald.conf directly (which package upgrades can prompt on), create a numeric drop-in directory override in the recommended 60-90 administrator range:

BASH
sudo mkdir -p /etc/systemd/journald.conf.d
sudo tee /etc/systemd/journald.conf.d/60-size-limit.conf >/dev/null <<'EOF'
[Journal]
Storage=persistent
SystemMaxUse=200M
SystemKeepFree=1G
EOF

Restart the journal daemon to apply the new limits:

BASH
sudo systemctl restart systemd-journald.service

Verification and Expected Result

Verify both the effective size limits and current disk usage after restarting systemd-journald:

BASH
journalctl --disk-usage
sudo journalctl -b -u systemd-journald.service -n 20 --no-pager

Expected result: journalctl --disk-usage reports total usage near or under 200M, the systemd-journald unit log shows the active SystemMaxUse / SystemKeepFree limits with no syntax errors, and systemctl --failed stays clean after you resolve the underlying unit failure.

Troubleshooting

  • Short-lived service prints zero lines even with `_PID=`: If a process exits immediately due to a missing binary or bad WorkingDirectory=, check journalctl -b _COMM=systemd or systemctl status <unit> for status=203/EXEC or status=200/CHDIR emitted by PID 1 itself.
  • Permission denied / missing logs as a regular user: Non-root users only see their own user journal unless added to the system journal group (adm on Ubuntu/Debian, systemd-journal on Arch, wheel on Fedora) or running with sudo.
  • Logs show truncated lines in terminal: Pass --no-pager when redirecting or copying, or override SYSTEMD_LESS=FRXMK (removing S) so less wraps long stack traces instead of chopping them at the right margin.

Sources