Blueprints · Systemd & Agents
Beginner
10 min · systemd
Logrotate and journald disk guard
Caps journald at 200 MB and rotates Nginx, Docker, and Laravel logs daily so a quiet host does not fill the disk.
Live config
Baked-in protections
- SystemMaxUse is 200M
- Nginx logs rotate daily and keep 14 files
- Docker json logs are covered when the daemon data root uses the default path
- Laravel storage logs rotate daily
Step 1 · ini
journald cap
/etc/systemd/journald.conf.d/portgate.conf
Vacuum runs after the cap is written.
[Journal] SystemMaxUse=200M SystemKeepFree=100M MaxRetentionSec=14day
Step 2 · conf
logrotate snippets
/etc/logrotate.d/portgate
Laravel path follows APP_PATH. Missing directories are skipped by logrotate.
/var/log/nginx/*.log {
daily
rotate 14
missingok
notifempty
compress
delaycompress
sharedscripts
postrotate
nginx -s reopen || true
endscript
}
/var/lib/docker/containers/*/*.log {
daily
rotate 7
missingok
copytruncate
compress
maxsize 10M
}
/var/www/app/shared/*.log /var/www/app/current/storage/logs/*.log {
daily
rotate 14
missingok
notifempty
compress
copytruncate
}
Step 3 · bash
Reload journald
/root/portgate-blueprints/journald-apply.sh
Creates the drop-in directory when the unit exists.
#!/bin/sh set -eu install -d -m 755 /etc/systemd/journald.conf.d systemctl restart systemd-journald || true journalctl --vacuum-size=200M || true