Daemon - syntaxe
Aller à la navigation
Aller à la recherche
Ci-dessous un exemple de démon (ou daemon) classique unix.
Les lignes "chkconfig" et "description" sont nécessaires pour être prises en charge par chkconfig sur les redhat.
#!/bin/bash
#
# Daemon example
#
# chkconfig: 345 99 01
# description: service description\
# for this daemon example.
#########################
### Functions ###
#########################
start() {
echo "Starting `basename $0`."
# insert command to start daemon
}
stop() {
echo "Stopping `basename $0`."
# insert command to stop daemon
}
status() {
echo "Status :"
# insert command to have daemon status
}
usage() {
echo "Usage : $0 {start|stop|restart|status}"
}
#########################
### Main ###
#########################
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
status)
status
;;
*)
usage
exit 1
;;
esac
exit 0