systemd Service Unit Generator
Pure frontend: fill in the form, copy the unit text. Nothing is sent anywhere, no systemctl command is called, and nothing is written to your disk.
How to use it
Enter a service name and command, choose a type and restart policy, and the full .service text is generated below. Copy it into /etc/systemd/system/<name>.service yourself, then decide when to reload and start. The generator performs no actions on your machine.
Three fields decide whether a unit survives
ExecStart needs absolute paths, including the interpreter. A system service does not read your login environment. Use /opt/myapp/.venv/bin/python /opt/myapp/main.py. Pipes, && and redirection are not interpreted by systemd; put them in a script file.
Do not skip User. Running a service as a least-privilege account is far cheaper than tightening things after an incident. Check that this account can read the executable, working directory and config file: many "service will not start" cases are permissions, not paths.
WorkingDirectory sets the base for relative paths. A system service starts in /, so open("config.json") looks in the root directory. The generator writes this field for you, but critical paths in the program should still be absolute. Belt and braces.
For network dependencies, use After=network-online.target together with Wants=network-online.target. network.target only says network units were started, not that addresses, routes and DNS are ready. Even with the right target, let the program retry outbound connections; systemd's ordering is not a readiness guarantee.
The oneshot trap: success can still show as dead
A one-shot task that exits with code 0 is still marked inactive (dead), because there is no process left. To keep it active (exited) so downstream units can depend on it, add RemainAfterExit=yes. The generator includes this line automatically when you pick oneshot.
Know its limits, though. RemainAfterExit preserves manager state; it is not an exactly-once guarantee. A reboot or explicit restart runs the task again, so the task itself must be safe to repeat. Repeating work belongs in a .timer paired with a .service, never in a oneshot with Restart=always.
Get the order right
After writing the file, run systemctl daemon-reload so systemd re-parses units, then systemctl enable --now <service> to start it and enable it at boot. Editing the file and calling restart alone reuses the in-memory version, which looks exactly like your change was ignored. systemctl cat <service> shows what is actually loaded.
A fixed order for "the service will not start"
Do not rewrite the unit immediately. First systemctl status <service> and read the active state and exit code: 203 usually means the ExecStart path is missing or not executable, while 1 means the program itself failed. Then journalctl -u <service> -n 100 --no-pager, which is the direct record of anything the program wrote to stdout or stderr. Then check permissions: the User in the unit needs execute rights on the binary and read rights on config files. On SELinux systems, look for AVC denials too.
Port conflicts are another common one. The program logs "address already in use" but runs fine by hand, because the earlier instance happened to exit by then. Check ss -lntp | grep <port>. Relative paths are similar: by hand your current directory is the code directory; under systemd it is /, so open("config.json") fails. WorkingDirectory in the unit handles that.
By default journals live in memory and disappear on reboot, which is unfortunate during an incident. Set Storage=persistent in /etc/systemd/journald.conf and cap it with SystemMaxUse so logs cannot fill the disk. That change affects every service, not just the new one.
Variables, and when not to use a service unit
Keep secrets out of the unit file: such files end up in configuration repositories and have loose permissions. Put them in a separate file, reference it with EnvironmentFile=/etc/myapp/env, tighten it to mode 600 and give it to the runtime user. Use KEY=value lines, no export, and no quotes unless the value genuinely contains them. Prefixing the path with a minus, EnvironmentFile=-/etc/myapp/env.local, makes an absent file non-fatal, handy for optional overrides.
Note the reload distinction: changing the referenced file needs no daemon-reload, because the unit itself did not change; changing any line in the unit does. People confuse the two and either reload unnecessarily or skip a required one.
Short, finite jobs that repeat on a schedule belong in a .timer plus .service, not a service with Restart. The timer decides when to trigger; the service does one unit of work. Giving a oneshot Restart=always tends to produce a restart loop or multiple runs with no clear record of when it last ran. Containers are their own story: units generated by Docker Compose or Podman are often transient, and daemon-reload does not affect them. Prefer the container runtime's own integration over hand-writing a unit around it.
Finally, do not add nohup or a trailing & to a program that can run in the foreground. systemd wants that foreground process; when the main process exits, the service is over. If the program only offers daemon mode, look for an official foreground flag first and consider Type=forking with PIDFile second. An extra shell layer makes $MAINPID point at the shell rather than your program, so stop leaves children behind.
For a real deployment, see Prometheus deployment and systemd. For startup troubleshooting notes, see PVE operations notes. The authoritative directive reference is the systemd.service manual.