Skip to content

Instantly share code, notes, and snippets.

@romanvm
Last active September 22, 2022 18:33
Show Gist options
  • Save romanvm/8c742c5d3ce4c52889fe0669fedcb358 to your computer and use it in GitHub Desktop.
Save romanvm/8c742c5d3ce4c52889fe0669fedcb358 to your computer and use it in GitHub Desktop.
Example of a simple Linux systemd service
[Unit]
Description=Example systemd service
After=network.target
StartLimitIntervalSec=0
[Service]
Type=simple
Restart=on-sucess
RestartSec=1
User=nobody
ExecStart=/bin/bash -c "tail -f /dev/null"
[Install]
WantedBy=multi-user.target
@romanvm
Copy link
Author

romanvm commented May 8, 2019

A .service file needs to be created in /etc/systemd/system directory. ExecStart path must be absolute.

Essential commands:

  • Enable: sudo systemctl enable <service-name>
  • Start: sudo systemctl start <service-name>
  • Stop: sudo systemctl stop <service-name>
  • Disable: sudo systemctl disable <service-name>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment