1. Home
  2. Developer
  3. systemd Service Generator

systemd Service Generator

Enter a command and options to get a systemd service and timer file.

For every format and option in one place, use Server Config Generators →

Runs in your browser · No upload
Do not put passwords or tokens here; use the environment file below.
Service file
[Unit] Description=My application After=network-online.target Wants=network-online.target [Service] Type=simple User=myapp Group=myapp WorkingDirectory=/opt/myapp ExecStart=/usr/bin/node /opt/myapp/server.js Restart=on-failure RestartSec=5 EnvironmentFile=/etc/myapp/myapp.env Environment="NODE_ENV=production" NoNewPrivileges=true PrivateTmp=true ProtectHome=true ProtectSystem=strict ReadWritePaths=/var/lib/myapp [Install] WantedBy=multi-user.target
Install and run
# create the service user if it does not exist sudo useradd --system --no-create-home --shell /usr/sbin/nologin myapp # create the environment file for secrets (systemd reads it as root, so 600 is enough) sudo mkdir -p /etc/myapp sudo touch /etc/myapp/myapp.env sudo chmod 600 /etc/myapp/myapp.env # save as /etc/systemd/system/myapp.service sudo systemd-analyze verify /etc/systemd/system/myapp.service sudo systemctl daemon-reload sudo systemctl enable --now myapp.service systemctl status myapp.service journalctl -u myapp.service -f
Review before using this on a production server. ProtectHome and ProtectSystem make writes to /home or system paths fail. Run systemd-analyze verify first.

Your input is processed in this browser and never sent to a server.

How to use

  1. Enter the service name, the command (ExecStart), the working directory, and the user and group. The command must be an absolute path such as /usr/bin/node.
  2. Set the restart policy, environment, environment file, hardening and memory or file limits as needed.
  3. For a recurring job, turn on the timer. The service becomes oneshot and a .timer file is generated too. A cron expression can be converted into the OnCalendar value.
  4. Save the files under /etc/systemd/system/ and run the systemd-analyze verify, daemon-reload and enable --now commands shown at the bottom in order.

Main settings

Setting Directive Notes
Service type Type= simple treats the ExecStart process as the service. Use oneshot for run-and-exit jobs and forking for programs that daemonize themselves
Restart Restart=, RestartSec= on-failure restarts only after an abnormal exit; always restarts even after a clean exit
Wait for network After=, Wants=network-online.target Starts once the network is up
Environment file EnvironmentFile= Keeps secrets out of the unit file. A leading - lets the service start without the file
Hardening NoNewPrivileges, PrivateTmp, ProtectSystem, ProtectHome Blocks privilege gain, gives a private /tmp, makes system and home directories read-only or hidden
Writable paths ReadWritePaths= Paths the app may write to under ProtectSystem=strict
Resources MemoryMax=, LimitNOFILE= Memory ceiling and open file limit

Cron expression to OnCalendar

With the timer on, a field converts a cron expression into OnCalendar. This tool gives:

Cron OnCalendar
0 3 * * * *-*-* 03:00:00
0 9 * * 1-5 Mon..Fri *-*-* 09:00:00
30 2 * * 0 Sun *-*-* 02:30:00
*/15 * * * * *-*-* *:00/15:00
0 0 1 * * *-*-01 00:00:00
0,30 9-17 * * * *-*-* 09..17:00,30:00

A cron expression with both day-of-month and weekday (0 0 13 * 5) runs when either one matches, but systemd needs both to match, so a warning is shown. For @reboot, use the timer’s OnBootSec instead of OnCalendar. To build or check the cron expression itself, use the Cron Expression Generator and the Cron Expression Parser.

Things to watch

  • ProtectHome=true hides everything under /home from the app. If the working directory is under /home, turn hardening off or move it. ProtectSystem=strict blocks writes everywhere except the paths in ReadWritePaths.
  • Do not write passwords or tokens in Environment=; move them to EnvironmentFile= and give the file mode 600. Unit files and systemctl show output are visible to other users. The chmod Calculator helps with the permission digits.
  • A % in an Environment value starts a systemd specifier, so this tool writes it as %%. Quotes and backslashes are escaped too.
  • Line breaks in input are replaced with spaces so nobody can slip extra directives into a field.
  • Review the generated unit before using it on a production server. Your app may also need TimeoutStopSec, ExecReload or logging settings.
  • Convert the environment file between formats with the Env Converter. If you run containers, the Dockerfile Generator and the Nginx Config Generator are the next steps.

Frequently asked questions

Where do I save the service file?

Put your own units at /etc/systemd/system/name.service. After saving, run sudo systemctl daemon-reload so systemd reads the new file.

Where do I look when the service will not start?

systemctl status name.service shows the state and the last log lines, and journalctl -u name.service -n 100 shows more. status=203/EXEC often means a wrong ExecStart path or missing execute permission.

Why use a timer instead of cron?

Logs go to the journal, Persistent=true runs missed jobs when the machine is back on, and the execution environment is managed as a service unit.

Type=simple or forking?

If the program stays in the foreground (most Node, Python and Go apps), use simple. For a traditional daemon that forks and lets the parent exit, use forking.

Is my input sent to a server?

No. The files are generated in your browser.

Your input is processed in this browser and never sent to a server.

Can't find the tool you need?

Tell us what you want to do. We build the most requested tools first.