How to use the systemd Service Generator
- Pick a preset — Node.js, Python with Gunicorn, a Go binary or a scheduled script — to fill sensible defaults.
- Set the command, working directory and the user it runs as (create it with
useradd --system; never run apps as root). - Add environment variables or an
EnvironmentFile, choose the restart policy and keep sandboxing on. - Copy the unit file to
/etc/systemd/system/and run the install commands shown.
The three sections of a unit file
| Section | Key settings |
|---|---|
[Unit] | Description, and After=/Wants=network-online.target so the app starts once networking is up |
[Service] | ExecStart (absolute path), User, WorkingDirectory, Environment, Restart and RestartSec |
[Install] | WantedBy=multi-user.target — what systemctl enable hooks the service into so it starts at boot |
Sandboxing
The hardening options make the service much safer with no code changes: NoNewPrivileges, ProtectSystem=strict (the filesystem is read-only except ReadWritePaths), ProtectHome, PrivateTmp, PrivateDevices and kernel protections. Check the result with systemd-analyze security my-app. If the app needs to write somewhere else, add that path to ReadWritePaths.
Timers instead of cron
A .timer unit starts a oneshot service on a calendar schedule. Unlike cron, its runs are logged in the journal, it can catch up on missed runs (Persistent=true) and you can see the next run with systemctl list-timers. To turn a cron line into an OnCalendar value, see the Cron Expression Generator.
Also searched as: systemd unit file generator, create systemd service, systemd service file, node js systemd service, python systemd service, systemd timer generator, linux service file.
Tools that pair well with the systemd Service Generator
- Nginx Config Generator — Choose what Nginx should do — serve a static site or SPA, proxy to a Node/Python app, or run PHP — and tick the extras.
- Dockerfile Generator — Choose your stack and get a production-ready Dockerfile: multi-stage build, cached dependency layer, non-root user, health check and a matching .dockerignore — explained line by line.
- Apache VirtualHost Generator — Get a complete Apache virtual host config for your domain: a static site, WordPress, PHP-FPM or a reverse proxy to a Node or Python app.
- Caddyfile Generator — Caddy gets HTTPS certificates automatically — you only describe your site.