Skip to content

Instantly share code, notes, and snippets.

@miere
Last active July 24, 2018 14:53
Show Gist options
  • Save miere/cf69e8eedd0c9af7a08b2b6aa32c63e6 to your computer and use it in GitHub Desktop.
Save miere/cf69e8eedd0c9af7a08b2b6aa32c63e6 to your computer and use it in GitHub Desktop.

Making CentOS applications start at boot

First of all, ensure you have a script which chkconfig is able to run. The file script.sh bellow is an useful script boilerplate in which you can use as starting point if don't have one.

Then, execute the following command:

$ chkconfig --level 345 script.sh on
#!/bin/sh
# chkconfig: - 99 10
start(){
echo "START"
}
stop(){
echo "STOP"
}
status(){
echo "STATUS"
}
usage(){
cat <<EOF
Usage: $APP <start|stop|status|restart>
EOF
}
case "$1" in
"start") start || exit 1;;
"stop") stop || exit 1;;
"restart") stop && start || exit 1;;
"status") status;;
*) usage; exit 1;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment