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

All unit files and timers commands · systemd and journalctl cheatsheet

Was this page helpful?