linux 服务 脚本,linux下进行服务管理的shell脚本

#!/bin/ksh

#------------------------------------------------------------------------------

# Program Name       :start.sh

# Description        :This program is for Menu to provide user various option to Start Various services & Server  #

# Parameters         :None

clear;

. $HOME/prog/RUN/shell/StartMgr/.exportParams

export LOG_PATH=$HOME/prog/RUN/shell/StartMgr

export LOGFNAME=StartMgr.log;

tput bold;

{

PS3="Please enter your choice (1-9):"

select  myselection in "Stop TED Server" "Start Informatica Server"  "Stop Informatica Server"  "Start Informatica Repository Server"   "Start WebSphere Server" "Stop WebSphere Server" "Clear the screen" "Quit" ;

do

case $myselection in

# Code to Stop TED Server

"Stop TED Server")

ping ted >> $LOG_PATH/$LOGFNAME 2>&1

if [ $? -eq 0 ]; then

printf "The TED server is already running..Would you like Stop the server y/nn";

read $input

#  if [[ $input -eq "y" ]]

echo " TED SERVER IS GETTING STOPPED.........within 10Min."

(

echo  "SYSTEM SHUTDOWN IN 10 MINUTES!" | wall

sleep 300; echo "SYSTEM SHUTDOWN IN 5 MINUTES!" | wall

sleep 240; echo "SYSTEM SHUTDOWN IN 1 MINUTE!" | wall

#sleep 60; shutdown

)&

#fi;

else

echo "STATUS CODE IS " $?

ping ted >> $LOG_PATH/$LOGFNAME 2>&1

fi;

;;

# Code to start Informatica Server starts here

"Start Informatica Server")

echo "Informatica Server is getting Started...."

# Start Code to start Infomatica Server

WORKING_DIR=`pwd`

# The following ps returns 1 if the pmserver is UP and 0 shen it is down

#RET_CODE=`ps -aef |grep pmserver|awk '{if ($3 == 1)  print 0; }'|grep -c 0`;

cd $INF_HOME

pmcmd pingserver -s $INF_SERVER:$INF_PORT >> $LOG_PATH/$LOGFNAME 2>&1

if [ $? -eq 0 ]; then

printf "The informatica server is already running..Stop server and startn";

else

pmserver $INF_CONFIG_FILENAME >> $LOG_PATH/$LOGFNAME 2>&1

#RET_CODE=`ps -aef |grep pmserver | awk '{if ($3 == 1)  print 0; }'|grep -c 0`;

echo "It may take around 60 seconds to Initialize the server.Plz Wait"

sleep 60

pmcmd pingserver -s $INF_SERVER:$INF_PORT >> $LOG_PATH/$LOGFNAME 2>&1

if [ $? -eq 0 ] ; then

print "PMsever started successfullyn "

else

printf "There is some problem in starting PMserver, Contact Administratorn See The Log in the location /ipc7/pc/TEDPROD4x.log"

fi;

fi;

cd $WORKING_DIR;

# End Code

;;

#Code to stop the Informatica Server

"Stop Informatica Server")

WORKING_DIR=`pwd`

cd $INF_HOME

echo " INFORMATICA SERVER IS GETTING STOPPED.........Plz Wait..."

#RET_CODE=`ps -aef |grep pmserver|awk '{if ($3 == 1)  print 0; }'|grep -c 0`;

pmcmd pingserver -s $INF_SERVER:$INF_PORT >> $LOG_PATH/$LOGFNAME 2>&1

if [ $? -eq 0 ]; then

(

# Run Background Alerts to all users

echo  "INFORMATICA SHUTDOWN IN 1 MINUTES!" | wall

sleep 30; echo "INFORMATICA SHUTDOWN IN 30 SECONDS!" | wall

)&

#To run in Background

echo "The Following command has been executed:"

echo "pmcmd shutdownserver -s $INF_SERVER:$INF_PORT -u $INF_USER -p $INF_PASSWD -stop"

pmcmd shutdownserver -s $INF_SERVER:$INF_PORT -u $INF_USER -p $INF_PASSWD -stop >> $LOG_PATH/$LOGFNAME 2>&1

if [ $? -eq 0 ] ; then

printf "PMserver stopped successfullyn";

else

printf "There is some problem in stopping PMserver, Contact Administratorn";

fi;

else

printf "PMserver already stoppedn"

fi;

cd $WORKING_DIR;

;;

#End code

# Code to start Informatica Repository Server starts here

"Start Informatica Repository Server")

echo "Informatica Repository Server is getting Started...."

# Start Code to start Infomatica Repository Server

WORKING_DIR=`pwd`

# The following ps returns 1 if the pmrepserver is UP and 0 then it is down

cd $INFREP_HOME

RET_CODE=`ps -aef |grep pmrepserver|grep ted4x| grep -v grep |awk '{if ($3 == 1)  print 0; }'|grep -c 0`;

if [ $? -eq 0 ]; then

printf "The Informatica Repository server is already running..Stop server and startn";

else

pmrepserver $INFREP_CONFIG >> $INFREP_LOGPATH/$INFREP_LOGFNAME 2>&1

# Start Agent also

#pmrepagent >> $INFREP_LOGPATH/$INFREP_LOGFNAME 2>&1

# pmserver $INF_HOME/$INF_CONFIG_FILENAME >> $LOG_PATH/$LOGFNAME 2>&1

#RET_CODE=`ps -aef |grep pmrepagent | awk '{if ($3 == 1)  print 0; }'|grep -c 0`;

echo "It may take around 60 seconds to Initialize the server.Plz Wait"

#pmcmd pingserver -s $INF_SERVER:$INF_PORT >> $LOG_PATH/$LOGFNAME 2>&1

#Need to Parametrize Username

sleep 60;

RET_CODE=`ps -aef |grep pmrepserver|grep ted4x| grep -v grep |awk '{if ($3 == 1)  print 0; }'|grep -c 0`;

if [ $? -eq 0 ] ; then

print "PMsever started successfullyn "

else

printf "There is some problem in starting PMserver, Contact Administratorn See The Log in the location /ipc7/pc/TEDPROD4x.log"

fi;

fi;

cd $WORKING_DIR;

# End Code

;;

# Code to start WebSphere Server starts here

"Start WebSphere Server")

echo "WebSphere Server is getting Started...."

# Start Code to strt WebSphere Server

WORKING_DIR=`pwd`

cd $WEBS_HOME

# The following ps returns 1 if the pmserver is UP and 0 shen it is down

#RET_CODE=`ps -aef |grep $WEBS_SERVERNAME |awk '{if ($3 == 1)  print 0; }'|grep -c 0`;

serverStatus.sh $WEBS_SERVERNAME -logfile $WEBS_LOGPATH/$WEBS_LOGFNAME | grep STARTED

if [ $? -eq 0 ]; then

printf "The WEBSPHERE server is already running..Stop server and startn";

#RET_CODE=`ps -aef |grep pmserver | awk '{if ($3 == 1)  print 0; }'|grep -c 0`;

else

echo "It may take around 60 seconds to Initialize the server.Plz Wait"

startServer.sh $WEBS_SERVERNAME -username $WEBS_USER -password $WEBS_PASSWD -logfile $WEBS_LOGPATH/$WEBS_LOGFNAME ;

if [ $? -eq 0 ] ; then

print "WEBSPHERE started successfullyn "

else

printf "There is some problem in starting WEBSPHERE, Contact Administratorn See The Log in the location " $WEBS_LOGPATH/$WEBS_LOGFNAME

fi;

fi;

cd $WORKING_DIR;

# End Code

;;

# Code to stop WebSphere Server starts here

"Stop WebSphere Server")

echo "WebSphere Server is getting Stop...."

# Start Code to stop WebSphere Server

WORKING_DIR=`pwd`

cd $WEBS_HOME

# The following ps returns 1 if the pmserver is UP and 0 then it is down

#RET_CODE=`ps -aef |grep $WEBS_SERVERNAME |awk '{if ($3 == 1)  print 0; }'|grep -c 0`;

serverStatus.sh $WEBS_SERVERNAME -logfile $WEBS_LOGPATH/$WEBS_LOGFNAME | grep stopped

if [ $? -eq 0 ]; then

printf "The WEBSPHERE server is already stopped..n";

#RET_CODE=`ps -aef |grep pmserver | awk '{if ($3 == 1)  print 0; }'|grep -c 0`;

else

echo "It may take around 60 seconds to Stop the server.Plz Wait"

(

echo  "WEBSPHERE SHUTDOWN IN 1 MINUTES!" | wall

sleep 30; echo "WEBSPHERE SHUTDOWN IN 30 SECONDS!" | wall

sleep 30;

)&

stopServer.sh $WEBS_SERVERNAME -username $WEBS_USER -password $WEBS_PASSWD -logfile $WEBS_LOGPATH/$WEBS_LOGFNAME -trace ;

if [ $? -eq 0 ] ; then

print "WEBSPHERE Stopped successfullyn "

else

printf "There is some problem in stopping WEBSPHERE, Contact Administratorn See The Log in the location " $WEBS_LOGPATH/$WEBS_LOGFNAME

fi;

fi;

cd $WORKING_DIR;

# End Code

;;

"Clear the screen") clear;;

"Quit") break ;;

*) echo "Invalid option"

;;

esac;

done

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值