Skip to content

Instantly share code, notes, and snippets.

@alistairtweed
Last active November 30, 2019 21:27
Show Gist options
  • Save alistairtweed/c7bc651997cfd5b587307bde69a6fdad to your computer and use it in GitHub Desktop.
Save alistairtweed/c7bc651997cfd5b587307bde69a6fdad to your computer and use it in GitHub Desktop.
systemd Startup Script
[Unit]
Description=<description>
[Service]
Type=<type:forking,oneshot...>
User=<user>
WorkingDirectory=<absolute path to working directory>
Environment=<environment variable>
ExecStart=/bin/bash <script to run on start>
ExecStop=/bin/bash <script to run on stop>
ExecReload=/bin/bash <script to run on reload>
Restart=<restart:on-failure,always...>
[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl enable my_service.service
sudo systemctl disable my_service.service
sudo systemctl start my_service.service
sudo systemctl stop my_service.service
sudo systemctl restart my_service.service
sudo systemctl reload my_service.service
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment