systemd and journalctl · Unit files and timers
Write a service unit
A service that runs an app as its own user and restarts it on failure. Save it as /etc/systemd/system/myapp.service.
[Unit]
Description=My app
After=network-online.target
Wants=network-online.target
[Service]
User=myapp
WorkingDirectory=/opt/myapp
ExecStart=/opt/myapp/bin/myapp
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target
Official systemd and journalctl documentation
More unit files and timers commands
- Reload unit files
- Override a unit safely
- Show a unit's effective definition
- Write a timer
- List timers
- Check a unit file for errors
All unit files and timers commands · systemd and journalctl cheatsheet