#!/bin/bash
export JAVA_HOME='/usr/local/jdk'
server='transfile_'
prefix="/var/instance/fileservice/transfer_file/${server}"
begin=0
end=9
function start() {
for (( i=$begin; i<=$end; i++ ))
do
echo "start $server$i now"
cd $prefix$i/
sh startup.sh
pid=$(ps -ef |grep -w "$server$i" |grep -v 'grep' |awk '{print $2}')
test "$pid" != '' && echo "start $server$i ok" || echo "start $server$i failed!"
sleep 1
done
}
function stop() {
for (( i=$begin; i<=$end; i++ ))
do
echo "stop $server$i now"
cd $prefix$i/
sh shutdown.sh
pid=$(ps -ef |grep -w "$server$i" |grep -v 'grep' |awk '{print $2}')
test "$pid" != '' && kill -9 $pid && echo "stop $server$i ok!" || echo "stop $server$i ok!"
sleep 1
done
}
function status() {
for (( i=$begin; i<=$end; i++ ))
do
pid=$(ps -ef |grep -w "$server$i" |grep -v 'grep' |awk '{print $2}')
test "$pid" != '' && echo "$server$i is running, and the pid is $pid" || echo "can not detect the pid of $server$i !"
done
}
function restart() {
for (( i=$begin; i<=$end; i++ ))
do
echo "restart $server$i now"
cd $prefix$i/
sh shutdown.sh
pid=$(ps -ef |grep -w "$server$i" |grep -v 'grep' |awk '{print $2}')
test "$pid" == '' && echo "stop $server$i ok!" || kill -9 $pid && echo "stop $server$i ok!"
sleep 1
sh startup.sh
pid=$(ps -ef |grep -w "$server$i" |grep -v 'grep' |awk '{print $2}')
test "$pid" != '' && echo "restart $server$i ok" || echo "restart $server$i failed!"
done
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status
;;
restart)
restart
;;
* )
echo "usage: $0 {start|stop|status|restart}"
exit 1
;;
esac
阅读(1958) | 评论(0) | 转发(0) |