systemd Service Generator
Fill in the fields and get a complete systemd .service unit — [Unit]/[Service]/[Install] sections, restart policy, and the install commands.
Fill in the fields — a complete systemd unit assembles live below, and empty
fields are left out. Save it to /etc/systemd/system/<name>.service and run
the install commands.
WantedBy=multi-user.target starts the service at boot in the
normal multi-user state. Use Type=notify only if your program calls
sd_notify(); forking only if it double-forks into the background.
For anything modern, simple (or exec) is right.
systemd units 101
What a unit file is
systemd runs services from unit files — INI-style text describing how to
start a program, what it depends on, and when to run it. It's the modern replacement for
init scripts. A service unit has three sections: [Unit] (metadata and ordering),
[Service] (how to run it), and [Install] (how it's enabled at boot).
[Unit] — metadata and ordering
| key | meaning |
|---|---|
Description | a one-line human label shown in systemctl status |
After | start this unit after the listed units (ordering only). network-online.target is common for network services |
Wants / Requires | pull in other units. Requires is a hard dependency — if it fails, this unit fails too; Wants is a soft one |
[Service] — how it runs
| key | meaning |
|---|---|
Type | simple (default — the process stays in the foreground), exec (like simple, waits for exec), forking (the process daemonizes itself), oneshot (runs once and exits), notify (signals readiness via sd_notify()) |
ExecStart | the command to run — must be an absolute path. Required. |
ExecStartPre / ExecStop | commands to run before start / on stop |
WorkingDirectory | the directory the process starts in |
User / Group | drop privileges to this account — don't run services as root unless they truly need it |
Environment | set an environment variable (repeatable); EnvironmentFile loads a file of them |
Restart | on-failure restarts after a crash; always restarts even on clean exit; pair with RestartSec to back off |
RemainAfterExit | treat a oneshot unit as "active" after its command finishes |
[Install] — enabling at boot
WantedBy=multi-user.target is the usual choice: when you
systemctl enable the unit, it's linked to start in the normal multi-user
(non-graphical) boot state. This section only matters for enable; it's ignored
when you start the unit manually.
Installing it
sudo cp myapp.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable --now myapp.service
systemctl status myapp.service
daemon-reload makes systemd re-read unit files after you add or edit one;
enable --now both enables it at boot and starts it immediately. Check
journalctl -u myapp.service for its logs.