标签: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
标签:tor put not star proc list rem .sh 脚本
原文地址:https://www.cnblogs.com/python-cat/p/10027978.html