You run du to find out why your VPS disk keeps creeping toward 100%, and the answer is a folder you've never touched: /var/log/journal, sitting at 3, 5, sometimes 10 GB. Logrotate is configured, your app logs are tiny, and yet the disk keeps filling. That's the systemd journal, and it plays by its own rules. Here's how to confirm it's the culprit, reclaim the space safely, and cap it so it never happens again.
Symptom: What It Looks Like
Journal bloat rarely announces itself. You'll usually notice one of these first:
df -h /shows the root partition at 85–100%, but your website files and databases don't add up to that.du -sh /var/logreturns several gigabytes, while the files under/var/log/nginxor/var/log/apache2are small.- Package updates fail with
No space left on device, or MySQL refuses to start. - Your disk-usage graph climbs in a slow, steady line instead of a sudden jump.
Confirm it in one command:
journalctl --disk-usage
If that prints something like Archived and active journals take up 6.2G in the file system., you've found your problem.
Cause: Why the Journal Gets So Big
journald stores logs from every systemd service, the kernel, SSH, cron and anything that writes to stdout under systemd. It doesn't use logrotate at all; it has its own retention settings in /etc/systemd/journald.conf. The default cap is 10% of the filesystem, up to a 4 GB ceiling. On a 40 GB VPS disk that's 4 GB of logs you probably never read.
A few things make it worse:
- A noisy service. A crash-looping app restarting every few seconds, a PHP-FPM pool logging every slow request, or a Docker container spamming stdout can write gigabytes a day.
- Brute-force SSH traffic. Every failed login attempt is a journal line. On an unprotected server facing the internet, that adds up quickly.
- Persistent storage on a small disk. When
/var/log/journalexists, logs survive reboots and keep piling up. Ten percent of a small disk is still a big chunk when you're already tight. - Corrupted journal files. After an unclean shutdown, journald may leave behind
.journal~files that never get cleaned up properly.
Fix: Reclaim the Space Safely
Never rm -rf /var/log/journal/* while journald is running. It can leave the daemon writing to deleted files, and the space won't come back until a restart. Use journalctl's built-in vacuum options instead.
Step 1: Find out who's doing the talking
Before you delete anything, check which unit is generating the noise. Otherwise you'll just be back here next month.
# Top talkers over the last day
journalctl --since "24 hours ago" -o json --output-fields=_SYSTEMD_UNIT \
| grep -o '"_SYSTEMD_UNIT":"[^"]*"' | sort | uniq -c | sort -rn | head
If one unit dominates the list, say myapp.service or sshd.service, look at its recent lines with journalctl -u myapp.service -n 50. A repeating error is a bug to fix, not just a log to trim.
Step 2: Rotate and vacuum
Force journald to close the active file first so it can be cleaned, then vacuum by size or age:
sudo journalctl --rotate
sudo journalctl --vacuum-size=500M
# or keep only the last two weeks:
sudo journalctl --vacuum-time=14d
Check the result:
journalctl --disk-usage
df -h /
You can combine both limits too: --vacuum-size=500M --vacuum-time=14d deletes whatever goes past either one.
Step 3: Verify and clear corrupted files
sudo journalctl --verify
Any file flagged as FAIL is safe to remove, but stop the daemon first:
sudo systemctl stop systemd-journald
sudo find /var/log/journal -name "*.journal~" -delete
sudo systemctl start systemd-journald
Prevention: Put a Hard Cap on It
Vacuuming is a one-time cleanup. To keep it fixed, set limits in journald's config. Rather than editing the main file, use a drop-in so package updates don't overwrite your changes:
sudo mkdir -p /etc/systemd/journald.conf.d
sudo nano /etc/systemd/journald.conf.d/size.conf
[Journal]
SystemMaxUse=500M
SystemKeepFree=2G
SystemMaxFileSize=50M
MaxRetentionSec=1month
Compress=yes
Apply it:
sudo systemctl restart systemd-journald
journalctl --disk-usage
Here's what each setting actually does:
| Setting | What it controls | Sensible VPS value |
|---|---|---|
SystemMaxUse | Maximum total journal size on disk | 200M–1G |
SystemKeepFree | Free space journald must always leave on the filesystem | 1G–2G |
SystemMaxFileSize | Size of each journal file before it rotates | 50M |
MaxRetentionSec | Delete entries older than this, whatever the size | 2week–1month |
Storage | persistent (disk), volatile (RAM only), auto | Leave at auto unless you're very tight on disk |
SystemKeepFree is the one people forget, and it's the real safety net. Even if a service goes haywire, journald stops writing before it eats the last 2 GB your database needs.
Fix the noise at the source
- SSH brute force: move to key-only auth and install fail2ban. Your journal shrinks, and the server gets safer too.
- Docker containers: if you use the
journaldlog driver, a chatty container lands straight in the journal. Set sensible log options in/etc/docker/daemon.json, or switch chatty containers tolocalwithmax-size. - Crash-looping services: add
StartLimitIntervalSecandStartLimitBurstto the unit so a broken service gives up instead of restarting 10,000 times a day. - Per-service rate limits:
LogRateLimitIntervalSec=30sandLogRateLimitBurst=1000in a unit's[Service]section throttle one noisy app without touching the others.
Keep an eye on it
Add a quick check to your weekly routine, or a cron alert:
Save this as /etc/cron.weekly/journal-check and make it executable with chmod +x:
#!/bin/sh
journalctl --disk-usage | mail -s "Journal size on $(hostname)" you@example.com
If you already run a monitoring tool like Netdata, set a disk-usage alert on / at 80%. That gives you days of warning instead of a midnight outage.
Quick Recovery Checklist
journalctl --disk-usage: confirm the journal is the problem.- Find the noisy unit and fix the actual error.
journalctl --rotatethen--vacuum-size=500M.- Add a drop-in with
SystemMaxUseandSystemKeepFree. - Restart journald and recheck
df -h.
Frequently Asked Questions
Is it safe to vacuum the journal on a production server?
Yes. journalctl --vacuum-* only removes archived journal files and never touches the active one, so running services aren't affected. The only thing you lose is old log history, so if you're in the middle of investigating an incident, export what you need first with journalctl -u service --since ... > incident.log.
Does logrotate manage the systemd journal?
No. Logrotate handles plain text files under /var/log. The binary journal in /var/log/journal is controlled only by journald's own settings, which is why a server can have perfectly tuned logrotate configs and still fill up.
Should I set Storage=volatile to stop journal files entirely?
Only on very small disks where you have a remote log system. Volatile storage keeps logs in RAM, so they disappear on every reboot, which is exactly when you'd want them to figure out why the server went down. A size cap with persistent storage is the better trade-off for most VPS setups.
Why didn't the space come back after I deleted journal files manually?
journald still had those files open, so the kernel couldn't free the blocks. Restart it with sudo systemctl restart systemd-journald, and check lsof +L1 for any other process holding deleted files.
Does this apply to cPanel/WHM servers?
Yes. AlmaLinux and CloudLinux servers running WHM use systemd-journald too, and the same drop-in config works there. On shared hosting you don't manage the journal, so if you're on a cPanel shared plan and seeing disk quota issues, look at your account's error logs and backups instead.
