Boneyard Tools

systemd Service Generator

Create a working systemd service without memorizing unit-file syntax. Fill in your command, user, environment and restart policy, and the [Unit], [Service] and [Install] sections build as you type. Copy the result or download a ready-to-install .service file.

How to generate a systemd service file

  1. Enter a description and the ExecStart command that launches your program.
  2. Set the user, working directory, environment variables, restart policy and type as needed.
  3. Copy the unit or download the .service file into /etc/systemd/system, then run systemctl daemon-reload.

Examples

Node app restarted on boot

ExecStart=/usr/bin/node /srv/app/server.js, user=appuser, restart=always, after=network.target
[Unit]
Description=My web app
After=network.target

[Service]
Type=simple
User=appuser
WorkingDirectory=/srv/app
ExecStart=/usr/bin/node /srv/app/server.js
Restart=always
RestartSec=5

[Install]
WantedBy=multi-user.target

One-shot maintenance task

ExecStart=/usr/local/bin/backup.sh, type=oneshot, restart=no
[Unit]
Description=Nightly backup

[Service]
Type=oneshot
ExecStart=/usr/local/bin/backup.sh
Restart=no

[Install]
WantedBy=multi-user.target

Frequently asked questions

What is a systemd service file?

It is a unit file that tells systemd how to start, stop and supervise a long-running program on Linux. It has three sections: [Unit] for metadata and ordering, [Service] for the command and runtime settings, and [Install] for when the service should start.

Where do I put the generated .service file?

Save it as something like myapp.service in /etc/systemd/system. Then run sudo systemctl daemon-reload, sudo systemctl enable --now myapp to load it, start it and have it run at boot.

What is the difference between Type=simple, forking and oneshot?

Use simple when your command stays in the foreground, which fits most apps. Use forking when the process daemonizes by forking and the parent exits. Use oneshot for short tasks that run once and finish, often paired with Restart=no.

When should I set After=network.target?

Add After=network.target when your service needs the network to be up before it starts, such as a web server or a client that connects to a remote host. It controls ordering, not a hard requirement, so pair it with the right dependency if the network is mandatory.

What does Restart=on-failure do?

It restarts the service only when it exits with an error or is killed, but not when it exits cleanly. Restart=always restarts it on any exit, and Restart=no never restarts it. RestartSec controls how long systemd waits before trying again.

Is my configuration sent to a server?

No. The unit file is generated entirely in your browser from the values you enter, so nothing you type, including commands or environment variables, is uploaded anywhere.

Related tools