码迷,mamicode.com
首页 > 其他好文 > 详细

tomcat启动脚本

时间:2018-11-27 19:34:06      阅读:141      评论:0      收藏:0      [点我收藏+]

标签:tor   put   not   star   proc   list   rem   .sh   脚本   

#!/bin/bash
#tomcat start.sh
NAME=tomcat
export JAVA_HOME=/usr/local/java/jdk1.8.0_181
Tomcat_Path=/data/tomcat/
Pid_List=`ps -ef |grep tomcat|grep -v "grep"| awk ‘{print $2}‘ |sed -n 1p`
Tomcat_Home=/data/tomcat
Tomcat_doc=/data/www/kstore
war=/htdocs/war/
module="boss mobile third"
Start_Scripts=/data/tomcat/bin/startup.sh
Shutdown_Scripts=/data/tomcat/bin/shutdown.sh
Log_Backup=/data/tomcat_log_backup
Remote_Host=192.168.1.110
if [ -d $Log_Backup ];then
    echo ""
else
    mkdir -p $Log_Backup
fi

#if [ -s /bin/ss ]; then
#    StatBin=/bin/ss
#else
#    StatBin=/bin/netstat
#fi

case $1 in
    start)
	echo "start run tomcat"
	if /bin/ps -ef | grep -q|grep -v grep tomcat;then
            echo "$NAME (pid:"$Pid_List") already running."
	    exit 1
        fi	
	$Start_Scripts
	if [ "$?" != 0 ] ; then
            echo "run faild"
            exit 1
        else
            echo -e "\033[32m tomcat run done \033[0m"
        fi
        ;;
    stop)
	echo "stop tomcat service"
	if ! /bin/ps -ef  | grep -v grep | grep -q tomcat;then
            echo "$NAME is not running"
            exit 1
        fi
	$Shutdown_Scripts
#        Pid_List=`ps -ef |grep tomcat|grep -v "grep"| awk ‘{print $2}‘`
	kill -9 $Pid_List
	if [ "$?" != 0 ] ; then
            echo " $NAME stopping failed"
            exit 1
        else
            echo -e "\033[32m tomcat service closed  \033[0m"
#############清空缓存##################################################	    
	    sync
            echo 3 > /proc/sys/vm/drop_caches
#############清空日志###################################################
	    mv $Tomcat_Path/logs/* $Log_Backup
############输出本地日志到天津服务器####################################
	    cd $Log_Backup
	    tar -zcvf "`date +%F-%H%M%S`_tomcat_log.tar.gz" $Log_Backup/*
	    rsync -az "`date +%F-%H%M%S`_tomcat_log.tar.gz" root@$Remote_Host:/tmp
		
        fi
        ;;
	
    *)
	echo "please input {start|stop|}"
	exit 1
	;;
esac

  

tomcat启动脚本

标签:tor   put   not   star   proc   list   rem   .sh   脚本   

原文地址:https://www.cnblogs.com/python-cat/p/10027978.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!