linux bash脚本监控启动停止weblogic服务的脚本写法
程序员文章站
2022-06-23 19:36:33
有时,linux系统需要做ha或者类似的功能,需要配置weblogic脚本来启动,停止,查看状态,可以如下方式写
命令形式:weblogic server start|s...
有时,linux系统需要做ha或者类似的功能,需要配置weblogic脚本来启动,停止,查看状态,可以如下方式写
命令形式:weblogic server start|stop|restart|status
### begin wls configration domain_name=base_domain server_name=aserver admin_url="t3://ip:7001" domain_path=/oracle/middleware/user_projects/domains/${domain_name} #使用这个命令得到weblogic对应服务进程的进程号 wls_pid=`ps -ef|grep java|grep =${server_name}|awk '{print $2}'` #user_name=`logname` user_name=`whoami` ## wls_memory user_mem_args="-xms2048m -xmx3096m -xx:permsize=256m -xx:maxpermsize=512m" export user_mem_args ### end wls configration ######### weblogic server start|stop|restart|status #用于等待进程启停 wait_for_pid () { try=0 case "$1" in 'created') while test $try -lt 7 ; do printf . try=`expr $try + 1` sleep 1 done wls_pid=`ps -ef|grep java|grep ${server_name}|awk '{print $2}'` if [ "$wls_pid" != "" ] ; then try='' fi ;; 'removed') while test $try -lt 35 ; do wls_pid=`ps -ef|grep java|grep ${server_name}|awk '{print $2}'` if [ "${wls_pid}" = "" ] ; then try='' break fi printf . try=`expr $try + 1` sleep 1 done ;; esac } #判断操作用户名,不能是root需要使用weblogic用户 if [ "$user_name" = "root" ] ; then echo "user_name is $user_name! plz use weblogic!" exit 1 fi #domain不能为空 if [ "$domain_name" = "" ] ; then echo "domain_name is not set! plz set domain_name!" exit 1 fi #service不能为空 if [ "$server_name" = "" ] ; then echo "server_name is not set! plz set server_name!" exit 1 fi #url不能为空 if [ "$admin_url" = "" ] ; then echo "admin_url is not set! using default admin_url!" fi #如果是查看状态命令 if [ "$1" = "status" ] then if [ "${wls_pid}" = "" ] ; then echo "no pid - $server_name is not running !" exit 1 else echo "$server_name is running !" exit 0 fi fi printf "terminating $server_name " if [ "${wls_pid}" = "" ] ; then echo "no pid - $server_name is not running !" else kill -9 $wls_pid wait_for_pid removed if [ -n "$try" ] ; then echo " failed " exit 1 fi echo " done ! " exit 0 fi #如果是停止命令,这里不使用这个 if [ "$1" = "stop" ] then echo "" else #启动命令 printf "starting $server_name " if echo $server_name|grep -q dmin ; then nohup sh $domain_path/bin/startweblogic.sh & else nohup sh $domain_path/bin/startmanagedweblogic.sh $server_name $admin_url & fi wait_for_pid created if [ -n "$try" ] ; then echo " failed " exit 1 else echo " done ! " exit 0 fi fi echo "to check the log, you may excute:" echo "tail -100f "
以上所述是小编给大家介绍的linux bash脚本监控启动停止weblogic服务的脚本写法,希望对大家有所帮助
上一篇: linux patch 命令小结(收藏)
下一篇: 纯css实现照片墙3D效果的示例代码