liunx weblogic服务启停脚本

  1 #!/bin/bash
  2 #sh xx.sh start xx项目  例如:sh autoWeblogic.sh start bius
  3 #经测试发现weblogic 启动大概需要完全启动成功35秒左右 停止大概需要1~7秒
  4 #如果多个项目可以把DOMAIN_NAME换成动态的参数进行传递
  5 ### BEGIN WLS Configration
  6 DOMAIN_NAME=appadmin
  7 SERVER_NAME=$2
  8 #得到服务器的ip
  9 IP=`ifconfig | grep "inet addr" | grep -v 127.0.0.1 | awk ‘{print $2}‘ | awk -F: ‘{print $2}‘`
 10 ADMIN_URL="t3://ip:8001"
 11 DOMAIN_PATH=/Oracle/Middleware/user_projects/domains/${DOMAIN_NAME}
 12 #使用这个命令得到weblogic对应服务进程的进程号 (grep -w ${SERVER_NAME}) 可以精确匹配
 13 #WLS_PID=`ps -ef|grep java|grep =${SERVER_NAME}|awk ‘{print $2}‘`
 14 WLS_PID=`ps -ef|grep java|grep -w ${SERVER_NAME}|awk ‘{print $2}‘`
 15 #USER_NAME=`logname`
 16 USER_NAME=`whoami`
 17 ## WLS_MEMORY
 18 USER_MEM_ARGS="-Xms2048m -Xmx3096m -XX:PermSize=256m -XX:MaxPermSize=512m"
 19 export USER_MEM_ARGS
 20 ### END WLS Configration
 21
 22 ######### Weblogic server start|stop|restart|status
 23 #用于等待进程启停
 24 wait_for_pid ()
 25 {
 26   try=0
 27     case "$1" in
 28       ‘created‘)
 29         while test $try -lt 35 ; do
 30         printf .
 31         try=`expr $try + 1`
 32         sleep 1
 33         done
 34         WLS_PID=`ps -ef|grep java|grep -w ${SERVER_NAME}|awk ‘{print $2}‘`
 35         if [ "$WLS_PID" != "" ] ; then
 36           try=‘‘
 37         fi
 38       ;;
 39       ‘removed‘)
 40         while test $try -lt 7 ; do
 41         WLS_PID=`ps -ef|grep java|grep -w ${SERVER_NAME}|awk ‘{print $2}‘`
 42         if [ "${WLS_PID}" = "" ] ; then
 43           try=‘‘
 44         break
 45         fi
 46         printf .
 47         try=`expr $try + 1`
 48         sleep 1
 49         done
 50       ;;
 51     esac
 52 }
 53 #判断操作用户名,不能是root需要使用weblogic用户
 54 if [ "$USER_NAME" = "root" ] ; then
 55   echo "USER_NAME is $USER_NAME! Plz use weblogic!"
 56   exit 1
 57 fi
 58 #domain不能为空
 59 if [ "$DOMAIN_NAME" = "" ] ; then
 60   echo "DOMAIN_NAME is not set! Plz set DOMAIN_NAME!"
 61   exit 1
 62 fi
 63 #service不能为空
 64 if [ "$SERVER_NAME" = "" ] ; then
 65   echo "SERVER_NAME is not set! Plz set SERVER_NAME!"
 66   exit 1
 67 fi
 68 #url不能为空
 69 if [ "$ADMIN_URL" = "" ] ; then
 70   echo "ADMIN_URL is not set! Using default ADMIN_URL!"
 71 fi
 72 #如果是查看状态命令
 73 if [ "$1" = "status" ]
 74   then
 75   if [ "${WLS_PID}" = "" ] ; then
 76    echo "No pid - $SERVER_NAME is not running !"
 77     exit 1
 78  else
 79   echo "$SERVER_NAME is running !"
 80   exit 0
 81  fi
 82 fi
 83
 84 #如果是停止命令
 85 if [ "$1" = "stop" ]
 86 then
 87 printf "Terminating $SERVER_NAME "
 88   if [ "${WLS_PID}" = "" ] ; then
 89     echo "No pid - $SERVER_NAME is not running !"
 90   else
 91     kill -9 $WLS_PID
 92   wait_for_pid removed
 93   if [ -n "$try" ] ; then
 94   echo " failed "
 95   exit 1
 96   fi
 97     echo " done ! "
 98     exit 0
 99  fi
100 else
101 #启动命令
102 printf "Starting $SERVER_NAME "
103  if [ "${WLS_PID}" = "" ] ; then
104     nohup sh $DOMAIN_PATH/bin/startWebLogic.sh &
105   else
106     kill -9 $WLS_PID
107   wait_for_pid removed
108   if [ -n "$try" ] ; then
109   echo "restart failed "
110   exit 1
111   fi
112     nohup sh $DOMAIN_PATH/bin/startWebLogic.sh &
113  fi
114   #if echo $SERVER_NAME|grep -q dmin ; then
115   #   nohup sh $DOMAIN_PATH/bin/startWebLogic.sh &
116   # else
117   #  nohup sh $DOMAIN_PATH/bin/startManagedWebLogic.sh $SERVER_NAME $ADMIN_URL &
118   # fi
119   wait_for_pid created
120   if [ -n "$try" ] ; then
121     echo " failed "
122     exit 1
123   else
124     echo " done ! "
125     exit 0
126   fi
127 fi
128 echo "To check the log, you may excute:"
129 echo "tail -100f "

原文地址:https://www.cnblogs.com/tzhyy/p/9217645.html

时间: 2024-10-09 23:42:07

liunx weblogic服务启停脚本的相关文章

Linux 程序启停脚本

start.sh #!/bin/sh java -jar ./program.jar & echo $! > /var/run/program.pid stop.sh #!/bin/sh PID=$(cat /var/run/program.pid) kill $PID 原文链接:Linux 程序启停脚本 - 零度空间

nginx 启停脚本

#! /bin/sh# chkconfig: 35 85 15# description: This is nginx start and stop script PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin DESC="nginx daemon" NAME=nginx DAEMON=/usr/sbin/$NAME CONFIGFILE=/etc/nginx/$NAME.conf PIDFILE=/v

专业规范的mysql启停脚本

#!/bin/sh########################################################ShellName:mysql启停脚本 ##Author:zkg ##Created Time:2019-08-23 ##Blog Address:https://blog.51cto.com/1009516 ######################################################## #调用系统函数库. /etc/init.d/f

Oracle BIEE启停脚本

作为BI的开发人员,经常启停BI服务在所难免,启动的过程又比较长,命令需要不同目录切换,简直烦死人呢, 特意整理了linux中的启动脚本,将以下脚本存成biee.sh,后面的过程就相当简单了, 启动:./biee.sh start 停止 :  ./biee.sh stop 重启:./biee restart 日志的观察: tail -f /var/log/obiee-start.log tail -f /var/log/obiee-stop.log 以下是脚本内容,保存成.sh文件,然后chmo

nginx启停脚本

安装nginx时,源码包中未带官方的启动脚本,也就无法使用service nginxd start这种启动方式,查了下资料自己写了一个: #!/bin/bash #@version: 0.0.1 #@author: lifafu #@file: #@time: 2017/02/04 08:00 #@company: source /etc/profile #加载系统环境变量 source $HOME/.bash_profile #加载用户环境变量 #set -o nounset #引用未初始化变

Redis启停脚本

环境:多实例环境,需指定端口进行启停服务 编写脚本: #!bin/sh#调用函数功能#这是redis的启动.停止.重启脚本REDISPORT=$1#redis的pidEXEC=/usr/local/redis4/bin/redis-server CONF="/etc/redis/${REDISPORT}.conf"CLIEXEC=/usr/local/redis4/bin/redis-cli#redis的PID文件位置,需要修改PIDFILE=/var/run/redis_${REDI

Onsql和MySQL的启停脚本

启停onesql,总共四个参数{start|stop|restart|status},只要稍微改一下头部的三个文件路径,即可完成mysql单实例的启停. [#9(zhouxx_vm(node3:192.168.56.103))#[email protected]~]#service onesql5.6.26 Usage:sh /etc/init.d/onesql5.6.26 {start|stop|restart|status} 详细执行效果如下: [#2(zhouxx_vm(node3:192

python启停脚本的编写

先占个位置,打算记录一下启停python 的脚本start.sh,stop.sh的写法. 内容包括启动python脚本的方式,日志的重定向,获取进程id,以及杀掉进程. 参考文章: http://blog.sina.com.cn/s/blog_61c006ea0100mkax.html https://www.cnblogs.com/evilliu/p/7682444.html https://www.cnblogs.com/zhangwuji/p/8059539.html 原文地址:https

weblogic启停脚本

weblogic启动 使用端口是否打开来判定服务是否启动. #!/bin/bash #author:wjf #date:2015/05/19 #测试环境为wls1036水平集群 v_curr_user=`whoami` v_start_user=uweblogic #------------用于安装和启动weblogic服务器的用户 v_admin_url=http://10.10.71.106:9001 #------------管理服务器的url v_dir_domain_bin=/webl