Skip to content

Instantly share code, notes, and snippets.

@glavk
Created August 27, 2021 13:55
Show Gist options
  • Save glavk/9297b6f41ca66e6ec59e9f4fabab821b to your computer and use it in GitHub Desktop.
Save glavk/9297b6f41ca66e6ec59e9f4fabab821b to your computer and use it in GitHub Desktop.
Shell script as daemon

Run shell script as daemon via systemd

Create a unit /etc/systemd/system/mydaemon.service:

[Unit]
Description=My daemon script

[Service]
ExecStart=/usr/local/bin/script.sh
Restart=on-failure

[Install]
WantedBy=multi-user.target 
systemctl enable mydaemon.service
systemctl start mydaemon.service 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment