shell-16: /etc/init.d/slurm-serverd

#!/bin/sh
#
# chkconfig: 2345  80 50
# description: slurm_server is for setup the socket at slurm side
#             
# processname: slurm_server 
#
# Source function library.
. /etc/rc.d/init.d/functions

ret=0
 
start() {
	echo "start slurm_server, setup the socket.."
	daemon /usr/local/bin/slurm_server &
	ret=$?
	exit $ret
}

stop() {
	echo "stop slurm_server"
	kill $(ps -ef | grep slurm_server | grep -v grep | awk '{print $2}')
	ret=$?
}
 
status() {
	local result
	echo "check status of slurm_server..."
	result=$( ps aux|grep slurm_server|grep -v grep| awk '{print $8}' )
	echo "result=$result"	
	#if [ "$result" = "Ss" -o "$result" = "R+" ]; then
	if [ "$result" = "Ss" ] || [ "$result" = "R+" ]; then
		echo "slurm_server is up"
		ret=0
	else
		echo "slurm_server is down"
		ret=1
	fi
}
 
case "$1" in
	start)
        	start
        	;;
  	stop)
        	stop
        	;;
  	status)
          	status
        	;;
  	*)
		echo $"Usage: $0 {start|stop|status}"
		exit 1
esac
 
exit $ret

你可能感兴趣的:(shell-16: /etc/init.d/slurm-serverd)