systemd Reference
v1.0.0Unit file directives for [Unit], [Service], [Install], [Timer], and [Socket] sections.
21 entries found
A free-form string describing the unit. Shown in systemctl status output.
[Unit] Description=My Application Server
Ensures this unit starts after the listed units. Does not create a dependency itself — combine with Wants or Requires.
[Unit] After=network.target postgresql.service
Ensures this unit starts before the listed units. The reverse of After.
[Unit] Before=nginx.service
Hard dependency. If any Requires unit fails to start, this unit is also deactivated.
[Unit] Requires=postgresql.service
Soft dependency. Starts the listed units together with this one but does not fail if they cannot start.
[Unit] Wants=redis.service
Only starts the unit if the given path exists. Prefix with ! to invert. Useful for optional-component units.
[Unit] ConditionPathExists=/etc/myapp/config.toml
Binds stop/restart propagation to the listed units. If the parent stops or restarts, so does this unit.
[Unit] PartOf=myapp.target
Controls how systemd considers the service started. Values: simple (default), exec, forking, oneshot, notify, dbus, idle.
[Service] Type=notify
Command to execute when starting the service. For oneshot services, multiple ExecStart entries are allowed.
[Service] ExecStart=/usr/bin/node /opt/myapp/index.js
Command to run when stopping the service. Receives the same environment as ExecStart.
[Service] ExecStop=/usr/bin/node /opt/myapp/stop.js
Command to reload the service's configuration without a full restart. Commonly sends SIGHUP.
[Service] ExecReload=/bin/kill -HUP $MAINPID
When to automatically restart the service. Values: no, always, on-success, on-failure, on-abnormal, on-watchdog, on-abort.
[Service] Restart=on-failure RestartSec=5s
Sets the user (and group) to run the service as. Strongly recommended to avoid running services as root.
[Service] User=myapp Group=myapp
Sets the working directory for ExecStart and related commands. Prefix ~ for the user's home directory.
[Service] WorkingDirectory=/opt/myapp
Sets environment variables for the service process. Use EnvironmentFile to load from a file.
[Service] Environment=NODE_ENV=production PORT=3000 EnvironmentFile=-/etc/myapp/env
Where to send stdout/stderr. Values: journal, syslog, kmsg, null, inherit, file:<path>. Default is journal.
[Service] StandardOutput=journal StandardError=journal
Sets the maximum number of open file descriptors for the service. Useful for high-concurrency servers.
[Service] LimitNOFILE=65536
Specifies which target to register the unit under when enabled. multi-user.target is the standard for most services.
[Install] WantedBy=multi-user.target
Additional units to enable/disable when this unit is enabled/disabled.
[Install] WantedBy=multi-user.target Also=myapp-watcher.service
Triggers activation at specified calendar times. Syntax: DayOfWeek Year-Month-Day Hour:Minute:Second. Use systemd-analyze calendar to validate.
[Timer] OnCalendar=*-*-* 02:00:00 Persistent=true
Triggers activation a specified time after the system was booted.
[Timer] OnBootSec=10min OnUnitActiveSec=1h