Skip to content

Instantly share code, notes, and snippets.

@Inobtenio
Created September 9, 2019 00:13
Show Gist options
  • Save Inobtenio/50a5f622fbbd7a2856c6a3d2f4247af0 to your computer and use it in GitHub Desktop.
Save Inobtenio/50a5f622fbbd7a2856c6a3d2f4247af0 to your computer and use it in GitHub Desktop.
Simple CLI tool to create a systemd service that executes on boot from any command. Usage: sudo bash make-service [name] [description] [command]
#!/bin/bash
cat > "/etc/systemd/system/${1}.service" << EOF
[Unit]
Description=$2
After=network-online.target
[Service]
Type=simple
User=%i
ExecStart=$3
[Install]
WantedBy=multi-user.target
EOF
systemctl --system daemon-reload
systemctl enable $1
systemctl start $1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment