Created
September 15, 2019 21:27
-
-
Save ahmed-abdelazim/0e20e14fc86689cedf3d908f9dc2706c to your computer and use it in GitHub Desktop.
Create a service from bash script on Ubuntu ( for startup )
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| bootscript=/root/run.sh | |
| servicename=customboot | |
| cat > $bootscript <<EOF | |
| #!/usr/bin/env bash | |
| echo "$bootscript ran at $(date)!" > /tmp/it-works | |
| EOF | |
| chmod +x $bootscript | |
| cat > /etc/systemd/system/$servicename.service <<EOF | |
| [Service] | |
| ExecStart=$bootscript | |
| [Install] | |
| WantedBy=default.target | |
| EOF | |
| systemctl enable $servicename |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment