Systemd Tricks We Use to Keep Services Boring
Last reviewed . Tool versions and defaults may have changed since, so check the commands against current docs.
Concrete systemd unit patterns that reduced flakiness: restart policies, resource limits, and structured logs.
On this page
After a few painful outages caused by homemade init scripts, we moved everything to systemd and wrote down the patterns that worked.
Pattern: Restart with Backoff
We had a service that occasionally failed to bind its port on boot.
```ini [Unit] Description=API service After=network-online.target Wants=network-online.target
[Service] ExecStart=/usr/local/bin/api Restart=on-failure RestartSec=5
[Install] WantedBy=multi-user.target ```
- Restart=on-failure + RestartSec gave the process room to recover without flapping.
Pattern: Non-Root with Limits
We saw file descriptor exhaustion during load tests.
- Added User=api and LimitNOFILE=65536.
- Used Ansible to roll the unit file change across the fleet.
Pattern: Journald as a Timeline
When something goes wrong, we start with:
- `journalctl -u api -b`
- `journalctl -u api --since "-15min"`
Systemd didn’t fix our code, but it made failures predictable and repeatable.
Cite this article
Kiril Urbonas (2025). Systemd Tricks We Use to Keep Services Boring. DevOpsNess. https://www.devopsness.com/blog/systemd-tricks-we-use-to-keep-services-boring
[Systemd Tricks We Use to Keep Services Boring](https://www.devopsness.com/blog/systemd-tricks-we-use-to-keep-services-boring) (Kiril Urbonas, DevOpsNess, 2025-03-05)
More from Linux
Explore more articles in this category
CVE-2026-98432: The CVSS 9.8 Linux TCP Bug Now Has an Exploit. Patched Node Images
A use-after-free in the IPv4 TCP handshake, present since Linux 4.4, now has a working exploit against MPTCP listeners, and every Go 1.24+ server is one by default. Which kernels are fixed and how to roll them through EKS, GKE and AKS.
CERN Left Red Hat for Debian: The CPU Baseline Lesson
CERN is moving accelerator control computers to Debian because RHEL raised its minimum CPU level. Check your own fleet's x86-64-vN support before the next OS upgrade does it for you.
ext4 vs XFS vs Btrfs: Choosing a Filesystem for a Server
The default filesystem your distro picks is not always the right one for your workload. Here is what actually differs and when each one wins.
You might have missed
Evergreen posts worth revisiting.