ava脚本
#!/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
阅读(2628) | 评论(1) | 转发(0) |