The SaveMyStuff logo for saving bookmarks, notes, checklists, and other stuff online.

Systemd Unit File Example

# This is a reference example for creating a systemd unit file # Showing the more common options [Unit] Description=Some Human Description After=network.target [Service] ExecStart=/opt/bin/app --config /etc/config.toml Type=simple # use oneshot for one-offs Restart=always User=anonymous Group=anonymous Environment="KEY=VALUE" # able to repeat PrivateTmp=yes NoNewPrivileges=true ProtectSystem=strict ReadWritePaths=/var/local/datafiles # DB files, e.g. AmbientCapabilities=CAP_NET_BIND_SERVICE # public port CPUQuota=100% # one core is 100% CPUWeight=300 # 1 to 10,000 (100 is default) OOMScoreAdjust=800 # -1000 is critical, 1000 is low priority MemoryLow=16M # reserved MemoryMax=128M # maximum [Install] WantedBy=multi-user.target (Restart options) no - service will not be restarted automatically on-success - restart only if service exits successfully (exit 0) on-failure - restart only if service exits with non-zero exit code on-abnormal - restart only if service terminates due to unclean signal (e.g. segfault) on-abort - restart only if service terminates due to unhandled signal always - restart regardless of exit reason, unless explicitly stopped by systemctl stop