首页 > 编程语言 > 详细

java程序脚本和tomcat脚本

时间:2014-03-25 15:20:58      阅读:450      评论:0      收藏:0      [点我收藏+]

java脚本

#!/bin/bash
# chkconfig: 345 99 1
# description: java progress
# processname: java
# authority :amos.lu
export PAHT=$PATH:/bin:/usr/bin:/usr/sbin:/sbin
export JAVA_HOME=/usr/local/jdk1.6.0_16
export JRE_HOME=/usr/local/jdk1.6.0_16
export LOGS_USER=root
export LOGS_HOME=/data/app/logs.playvip
export OPT="-jar -server -Xms512m -Xmx1024m"
export JAVA="/usr/local/jdk1.6.0_16/bin/java"
export NOHUP="/usr/bin/nohup"
. /etc/init.d/functions
#[ -d LOGS_HOME ] || { echo " sales requires LOGS_HOME"; exit 1; }
JAR=`ls $LOGS_HOME|grep jar|grep -v grep|head -n1`
usage() {
        echo "Usage: $0  {start|stop|restart|status}"
        exit 2
}
function start()
{
        if ps -ef | grep "$JAR" | grep -v grep >/dev/null
        then
                [ $? -eq 0 ] && echo "$JAR is already running.."
        else
                $NOHUP $JAVA $OPT $LOGS_HOME/$JAR   >>$LOGS_HOME/nohup.out 2>&1 &
                if [ $? -eq 0 ]
                then
                        echo -e "[ \e[1;32m OK \e[0m ]"
                else
                        echo -e "[ \e[1;31m failed \e[0m ]"
                fi
        fi
}
function stop()
{
        if ps -ef | grep -w "$JAR" | grep -v grep|awk ‘{print $2}‘>/dev/null
        then
                ps auxw|grep  $JAR|grep -v grep |awk ‘{print $2}‘|xargs kill -9 &>/dev/null
                if [ $? -eq 0 ]
                then
                        echo -e "[ \e[1;32m OK \e[0m ]"
                else
                        echo -e "[ \e[1;31m failed \e[0m ]"
                fi
        fi
}
function status()
{
        if ps -ef |grep  -w "$JAR"|grep -v grep >/dev/null
        then
                echo "$JAR is aleady running.."
        else
                echo "$JAR is not running.."
        fi
}
case $1 in
        start)
        start
        ;;
        stop)
        stop
        ;;
        status)
        status
        ;;
        restart)
        stop
        start
        ;;
        *)
        usage
        ;;
esac
exit 0

tomcat脚本

#!/bin/bash
# chkconfig: 345 99 1
# description: java progress
# processname: java
# authority :amos.lu
export PAHT=$PATH:/bin:/usr/bin:/usr/sbin:/sbin
export JAVA_HOME=/usr/local/jdk1.6.0_16
export JRE_HOME=/usr/local/jdk1.6.0_16
export LOGS_USER=root
export LOGS_HOME=/data/app/logs.playvip
export OPT="-jar -server -Xms512m -Xmx1024m"
export JAVA="/usr/local/jdk1.6.0_16/bin/java"
. /etc/init.d/functions
JAR=`ls $LOGS_HOME|grep jar|grep -v grep|head -n1`
usage() {
        echo "Usage: $0  {start|stop|restart|status}"
        exit 2
}
function start()
{
        if ps -ef | grep "$JAR" | grep -v grep >/dev/null
        then
                [ $? -eq 0 ] && echo "$JAR is already running.."
        else
                su - $TOMCAT_USER bash -c "$CATALINA_HOME/bin/catalina.sh $1 >/dev/null 2>&1";
                if [ $? -eq 0 ]
                then
                        echo -e "[ \e[1;32m OK \e[0m ]"
                else
                        echo -e "[ \e[1;31m failed \e[0m ]"
                fi
        fi
}
function stop()
{
        if ps -ef | grep -w "$JAR" | grep -v grep|awk ‘{print $2}‘>/dev/null
        then
                ps auxw|grep  $JAR|grep -v grep |awk ‘{print $2}‘|xargs kill -9 &>/dev/null
                if [ $? -eq 0 ]
                then
                        echo -e "[ \e[1;32m OK \e[0m ]"
                else
                        echo -e "[ \e[1;31m failed \e[0m ]"
                fi
        fi
}
function status()
{
        if ps -ef |grep  -w "$JAR"|grep -v grep >/dev/null
        then
                echo "$JAR is aleady running.."
        else
                echo "$JAR is not running.."
        fi
}
case $1 in
        start)
        start
        ;;
        stop)
        stop
        ;;
        status)
        status
        ;;
        restart)
        stop
        start
        ;;
        *)
        usage
        ;;
esac
exit 0


本文出自 “秋风颂” 博客,请务必保留此出处http://qiufengsong.blog.51cto.com/7520243/1383782

java程序脚本和tomcat脚本,布布扣,bubuko.com

java程序脚本和tomcat脚本

原文:http://qiufengsong.blog.51cto.com/7520243/1383782

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!