What is a systemd unit and why use this builder?
On modern Linux (Ubuntu, Debian, Fedora, Arch, Rocky, Alma...) systemd is the program that starts services at boot, restarts them when they crash, and runs scheduled jobs. A unit file is a small text file in `/etc/systemd/system/` that tells systemd *what* to run and *how* to behave.
This builder writes two kinds of units for you:
- `.service` ExecStart files for long-running programs (a Node web app, a Python worker, a database).
- `.timer` OnCalendar files for jobs that should run on a schedule (the modern replacement for cron).
Pick a preset, fill in the fields, copy the result into a file under `/etc/systemd/system/`, run `sudo systemctl daemon-reload && sudo systemctl enable --now myapp.service`, and you are done. Everything happens in your browser, no upload, no account.
How to use it
- Pick a preset that resembles your case (Node web app, Python worker, one-shot backup, database, Go binary, docker compose, static server). The form fills with sensible defaults you can tweak.
- Set the unit name (`myapp` becomes `myapp.service`), the Description (shown in `systemctl status`), and the dependencies (After, Wants, Requires, where almost everyone wants `network-online.target`).
- In the Service section pick a Type (use `simple` for most apps, `oneshot` for scripts that run and exit, `forking` for daemons that fork to the background), the User and Group to drop privileges, and ExecStart with the absolute path to your binary.
- Choose a Restart policy. `on-failure` is the safe default: systemd restarts only if your program exits non-zero or crashes. `always` is for long-lived workers that must come back no matter what. Use RestartSec to set a back-off (5 seconds is fine).
- Add Environment variables (NODE_ENV, DATABASE_URL...). Sensitive ones (passwords, tokens) belong in `EnvironmentFile=` instead: put them in a `chmod 600` file outside the unit.
- Optional hardening: turn on `PrivateTmp`, `ProtectSystem`, `NoNewPrivileges`. These cost nothing and limit damage if the service is compromised. The builder explains each.
- Switch to the .timer tab if you want a scheduled run instead of (or in addition to) the long-running service. Fill in OnCalendar (e.g. `daily`, `Mon *-*-* 03:00:00`), turn on Persistent so a missed run executes after a reboot, point Unit at your service.
- Click Copy or Download. Place the file at `/etc/systemd/system/myapp.service` (and `myapp.timer` if applicable), then run `sudo systemctl daemon-reload`, `sudo systemctl enable --now myapp.service`, and watch logs with `journalctl -u myapp.service -f`.
When this is useful
Seven concrete situations where a proper systemd unit saves real time:
- You wrote a Node, Python, or Go program and want it to start at boot and restart on crash. Drop a `.service` in `/etc/systemd/system/` and forget about `pm2`, `forever`, `screen`, or `nohup`.
- You have a script that should run on a schedule (nightly backup, weekly report, hourly cache refresh). A `.timer` plus `.service` pair is the modern replacement for cron and logs go straight to journalctl.
- You need to run a program as a non-root user with controlled permissions. `User=` and `Group=` drop privileges; `ProtectSystem=strict`, `PrivateTmp=yes`, and `NoNewPrivileges=yes` add hardening for free.
- You manage a small fleet and want the same service definition across machines. The unit file is plain text: version it in git, deploy with ansible / a Makefile / scp.
- You need a service to wait for the network or a database before starting. `After=network-online.target` and `Requires=postgresql.service` make the ordering explicit.
- A docker compose stack should start on boot. A oneshot `.service` with `ExecStart=docker compose up -d` plus `Requires=docker.service` handles it cleanly.
- You want centralized logs without configuring anything. `StandardOutput=journal` (the default) means `journalctl -u myapp` tails your program and `journalctl --since "1 hour ago"` is your single search.