Skip to main content

Run Script as a Service

Overview on systemd unit files

Config File

/etc/systemd/system/name.service

[Unit]
Description=
After=reboot.target network.target
StartLimitBurst=5
StartLimitIntervalSec=0

[Service]
Type=simple
Restart=always
# Use number as `seconds`
RestartSec=1min
RemainAfterExit=true
User=<username>
ExecStart=/bin/bash /path/to/<name>.service

[Install]
# Location to store service on `enable`
WantedBy=multi-user.target
Alias=<name>.service

Commands

Start service

Restart service

Add service to startup