Free tools / systemd service generator
Systemd service file generator
Turn a command that runs your app into a systemd service that starts on boot, restarts after a crash and logs to the journal. Set the user, working directory and environment, choose a restart policy and optional sandboxing, and get the unit file for /etc/systemd/system with the commands to enable it.
Everything runs in your browser. Nothing you type is sent to a server or stored.
Service
Environment
Restart and startup
Hardening
# /etc/systemd/system/myapp.service
# Generated at nocthost.com/tools/systemd-service-generator
[Unit]
Description=My app
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
User=myapp
Group=myapp
WorkingDirectory=/opt/myapp
Environment="NODE_ENV=production"
Environment="PORT=3000"
ExecStart=/usr/bin/node /opt/myapp/server.js
Restart=on-failure
RestartSec=5
# Hardening
NoNewPrivileges=true
PrivateTmp=true
[Install]
WantedBy=multi-user.target
# 1. Create the service user once (skipped if it already exists)
id -u myapp >/dev/null 2>&1 || sudo useradd --system --no-create-home --shell /usr/sbin/nologin myapp
# 2. Save the unit file
sudo nano /etc/systemd/system/myapp.service
# 3. Load it, start it now and on every boot
sudo systemctl daemon-reload
sudo systemctl enable --now myapp
# 4. Check it and follow the logs
systemctl status myapp
journalctl -u myapp -f
How to use
- Enter the command that starts your app, with the full path to the program. which node or which python3 shows it.
- Set a user other than root, the working directory and any environment variables the app needs.
- Choose a restart policy and the hardening options. With ProtectSystem=strict, list every directory the app writes to.
- Save the unit file, then run the daemon-reload and enable --now commands.
- Check that it runs with systemctl status and follow the logs with journalctl -u and the service name.
Frequently asked questions
Restart=always or Restart=on-failure?
on-failure restarts the app when it crashes, is killed or exits with an error, but not after a clean exit. always also restarts after a clean exit, which suits bots and workers that should never stop. Both respect systemctl stop.
Why not run the service as root?
Whatever the app can do, an attacker who finds a bug in it can do too. A dedicated system user without a login shell limits the damage to the files that user owns. The commands include a useradd line that creates one.
Where do I put secrets like API keys?
Unit files are readable by every user on the server, and systemctl show prints Environment values. Put secrets in a separate file, owned by root with chmod 600, and point EnvironmentFile at it. systemd reads it as root before it starts the app.
Why does my command work in the shell but fail as a service?
systemd does not run ExecStart through a shell and does not load your .bashrc. Pipes, redirects, && and ~ do not work, and PATH is minimal. Use full paths, WorkingDirectory instead of cd, and wrap shell syntax in /bin/bash -c if you need it.
Further reading
More free tools
- SSH hardening config generatorKey-only login, root off, AllowUsers, timeouts and modern ciphers as a drop-in or a full sshd_config.
- UFW firewall rules generatorOrdered ufw commands from presets or custom ports, with SSH allowed before the firewall turns on.
- Cloud-init user-data generatorA #cloud-config file for first boot: sudo user, SSH key, updates, ufw, fail2ban, auto updates and swap.
- WireGuard config generatorA server wg0.conf and up to 10 client configs with browser-generated keys, NAT rules and setup commands.
- Nginx reverse proxy config generatorAn nginx server block for a local app with Let's Encrypt HTTPS, WebSocket, redirects, gzip and rate limiting.
Need a server to run it on? Deploy an Ubuntu VPS