Skip to content

Instantly share code, notes, and snippets.

@haxpor
Created April 7, 2022 03:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save haxpor/0cee9e5988ce44937d078d783ae7c85d to your computer and use it in GitHub Desktop.
Save haxpor/0cee9e5988ce44937d078d783ae7c85d to your computer and use it in GitHub Desktop.
rc script to execute command(s) when system is up or down. Note the header lines which is required to have.
#!/bin/bash
### BEGIN INIT INFO
# Provides: <your service name>
# Required-Start: $network $syslog
# Required-Stop: $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 6
# Short-Description: execute commands when system is up or down
# Description: execute commands when system is up or down
### END INIT INFO
case "$1" in
start)
<do something here when system is up>
;;
stop)
<do something here when system is down>
;;
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment