Systemd and Modern Linux Service Management
Run services reliably with systemd: units, dependencies, and resource limits.
Key takeaways
Run services reliably with systemd: units, dependencies, and resource limits.
On this page
Systemd and Modern Linux Service Management#
Systemd is the standard for service management on most Linux distros. Use it for reliability and observability.
Unit Basics#
[Unit]
Description=My App
After=network-online.target
Wants=network-online.target
[Service]
Type=exec
ExecStart=/usr/local/bin/myapp
Restart=on-failure
RestartSec=5
User=app
LimitNOFILE=65536
[Install]
WantedBy=multi-user.target
Best Practices#
- Restart=on-failure with RestartSec to avoid tight restart loops.
- User= non-root; use CapabilityBoundingSet and NoNewPrivileges when possible.
- LimitNOFILE, LimitNPROC to avoid resource exhaustion.
- After=network-online.target so the app starts when the network is ready.
Logging#
- journald: Use StandardOutput=journal and StandardError=journal; query with journalctl -u myapp -f.
Systemd gives you a consistent way to run and debug services across environments.
Get the DevOps Troubleshooting Cheat Sheet
Subscribe and get our free one-page reference for the errors that eat an afternoon — CrashLoopBackOff, OOMKilled, Terraform state locks, and more — plus new guides as we publish them.
Edge Computing with AWS: CloudFront and Lambda@Edge
We use CloudFront + Lambda@Edge for specific patterns. The wins, the production gotchas, and where we hit Lambda@Edge's limits.
Systemd Service Management: Creating and Managing Services
A practical guide to writing and managing systemd services for production. The unit file features that earn their place, plus the operational workflows.
More from Linux
Explore more articles in this category
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.
journald Log Management: Retention, Filtering, and Forwarding
journald is the default log sink on every systemd distro, and most of it runs on defaults nobody chose. Here is how to actually control it.
DNS Troubleshooting on Linux: A Systematic Approach
\"It's always DNS\" is a joke because the failure modes are so scattered: resolver config, caching, search domains, split DNS. Here is where to actually look.
You might have missed
Evergreen posts worth revisiting.