sh - 脚本学习 启动/停止/重启/部署jetty crontab
===============jettytest.sh ======================
#!/bin/sh
jettysh_path=/usr/local/jetty/bin/jetty.sh
#jetty目录
jetty_home=/usr/local/jetty
#当前目录绝对路径
now_path=$(dirname $(readlink -f $0))
#jetty项目部署路径
jetty_workPath="/usr/local/jetty/webapps/ROOT/"
#部署war文件
RestUserWar=${now_path}/RestUser.war
NO_START=0
ACTION=$1
#NAME=$(echo $(basename $0) | sed -e 's/^[SK][0-9]*//' -e 's/\.sh$//')
#echo 当前路径now_path ${now_path}
echo ${jetty_workPath}
function deployJetty(){
 echo ”准备部署...”
 #sleep 1
 if [ -d "$jetty_workPath" ]
  then
   echo "目录下已存在,是否重新部署?(y/n)"
   read -p "请输入:" aoso
   [ -z ${aoso} ] && aoso="n"
  if [ "${aoso}" == "y" ] || [ "${aoso}" == "y" ] 
   then
    echo "开始清理目录 ${jetty_workPath} ..."
    rm -rf ${jetty_workPath} >/dev/null 2>&1
    sleep 1
    echo "清理完成" 
  else
    echo "退出部署"
    exit 1
  fi
fi
  if [ ! -s "$RestUserWar" ]
   then
    echo "没有找到war包,请将war包置入本目录下.."
  else
    echo "正在解压项目……"
     unzip -o RestUser.war -d ${now_path}/ROOT
     sleep 5      
    if [ $? -ne 0 ]
     then
      echo "项目解压失败!"
      exit 1
    fi
    if [ $? -eq 0 ]
     then
       echo "解压完成……" 
       echo "正在部署"
       mv ${now_path}/ROOT ${jetty_workPath} 
     fi
     sleep 2
     if [ $? -eq 0 ]
      then
       echo "部署完成"
       rm -rf ${now_path}/ROOT
       exit 0
      else
       echo "部署失败"
       rm -rf ${now_path}/ROOT
       echo "清理解压文件"	
       exit 1
      fi
  fi
}
case "$ACTION" in
 start)
  echo -n " 尝试启动 jetty... "
  cd  ${jetty_home}/bin
#if(( NO_START )); then
  ./jetty.sh start
  cd ${now_path}
;;
stop)
  echo -n " 尝试关闭 jetty... "
  cd  ${jetty_home}/bin
  ./jetty.sh stop
  cd ${now_path}
;;
restart)
   echo -n " 重启jetty .. "
   cd  ${jetty_home}/bin
   ./jetty.sh restart
   cd ${now_path}
;;
deploy)
  deployJetty
;;
  *)
  echo "命令: start | stop | restart | deploy"
esac
===================logcp.sh====================================
#!/bin/sh
cur_time=`date +%Y-%m-%d_%H:%M:%S`
log_path=/usr/local/nginx/logs
log=${log_path}/access.log
log_cut_path=${log_path}/awklog
log_cut=${log_cut_path}/access.${cur_time}.log
echo ${cur_time}
cp $log $log_cut
echo "" > $log
============================totaltest ===================================
#!/bin/sh
data_now=`date +"%Y-%m-%d %H:%M:%S"`
cur_time=`date +%Y%m%d_%H%M%S`
log_dir=/usr/local/nginx/logs
#nginx日志路径
nginx_accesslog=/usr/local/nginx/logs/access.log
nginx_curlog=${log_dir}/awklog/log_${cur_dir}.log
#controller以及项目日志路径
work_log_Path=/usr/local/RestUser/logs
#log
debug_log=${work_log_Path}/restUser_debug.log
error_log=${work_log_Path}/restUser_error.log
#统计行数
echo 当前时间 >> body.txt
#${data_now}  >> body.txt
uptime >> body.txt
echo 总数据:>> body.txt
cat ${nginx_accesslog} | wc -l >> body.txt
echo 总访问HTTP >> body.txt
grep -o 'HTTP/1' ${nginx_accesslog} | wc -l >> body.txt
echo 访问时长 最长的前五个 >> body.txt
#cat ${nginx_accesslog} | awk '{pring $24}'
#cat /usr/local/nginx/logs/access.log | awk '{print $24}'
awk '{print $24}' ${nginx_accesslog} | sort -nr | head -n 5  >> body.txt
echo 统计ip 去掉重复值  >> body.txt
awk '{print $1}' ${nginx_accesslog} | sort -n | uniq | wc -l  >> body.txt
echo 查看ip访问最多的前五个  >> body.txt
awk '{print $1}' ${nginx_accesslog} | sort | uniq -c | sort -rn | head -n 5  >> body.txt
echo 统计info记录数:  >> body.txt
grep "info 日志记录" ${debug_log} | wc -l  >> body.txt
echo controller响应时长 最快: >> body.txt
grep "Controller开始时间" ${debug_log} | awk '{print $9,$10}' | sort -rn | head -n 1 >> body.txt
echo db响应时长 最快: >> body.txt
grep "UserServiceImpl开始时间" ${debug_log} | awk '{print $9,$10}' | sort -rn | head -n 1 >> body.txt
echo controller 最慢: >> body.txt
grep "Controller开始时间" ${debug_log} | awk '{print $9,$10}' | sort -n | head -n 1 >> body.txt
echo db响应时长 最慢: >> body.txt
grep "UserServiceImpl开始时间" ${debug_log} | awk '{print $9,$10}' | sort -n | head -n 1 >> body.txt
read -p "是否发送邮件[y/n]: " aoso
 [ -z ${aoso} ] && aoso="n"
 if [ "${aoso}" == "y" ] || [ "${aoso}" == "Y" ]
  then  
    echo "发送邮件中……"
    mail -s 'Test mail' 0394anger@163.com < body.txt
  else
    echo "没有发送邮件"
 fi
============================sendmail===================================
vi /etc/mail.rc
# sendmailconfig
set from=0394anger@163.com
set smtp=smtp.163.com
set smtp-auth-user=0394anger@163.com
set smtp-auth-password=sqm
set smtp-auth=login
============================ crontab ===================================
[root@VM_129_126_centos ~]# crontab -e
*/1 * * * * /usr/local/qcloud/stargate/admin/start.sh > /dev/null 2>&1 &
0 0 * * * /usr/local/testsh/logcp.sh
============================ ===================================
============================ ===================================
============================ ===================================
sh - 脚本学习 启动/停止/重启/部署jetty crontab的更多相关文章
- Shell脚本_启动停止重启sh脚本
		1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 3 ... 
- Linux Systemd——在RHEL/CentOS 7中启动/停止/重启服务
		RHEL/CentOS 7.0中一个最主要的改变,就是切换到了systemd.它用于替代红帽企业版Linux前任版本中的SysV和Upstart,对系统和服务进行管理.systemd兼容SysV和Li ... 
- 在CentOS 7中启动/停止/重启服务
		RHEL/CentOS 7.0中一个最主要的改变,就是切换到了systemd.它用于替代红帽企业版Linux前任版本中的SysV和Upstart,对系统和服务进行管理.systemd兼容SysV和Li ... 
- linux如何启动/停止/重启MySQL
		如何启动/停止/重启MySQL 一.启动方式 1.使用 service 启动:service mysqld start2.使用 mysqld 脚本启动:/etc/inint.d/mysqld star ... 
- 批处理命令行CMD启动停止重启IIS的命令
		原文:批处理命令行CMD启动停止重启IIS的命令 启动IIS: net start iisadmin (IIS的整个服务) net start w3svc (WWW网页WEB服务) ... 
- Linux编辑启动停止重启springboot jar包脚本
		springboot的配置文件中,配置文件的名字都有各自的意义跟用途 dev 开发环境 prod 生产环境(默认) test 测试环境 加载指定配置文件 --spring.profiles.activ ... 
- .xxx.sh脚本无法启动,原来都是特殊字符搞的鬼?
		今天遇到个趣的问题,linux上springboot启动,连接达梦数据库报错. 解决思路: 1)是不是数据库本身有问题,客户端登录没问题. 2)排查是不是war包问题,本地连接数据库,没问题. 3)是 ... 
- sh脚本学习之: sh脚本 、sed、awk
		sh脚本 sh命令的批处理文件,支持更复杂的逻辑. Shell中的变量 参数 $0 当前脚本路径 $1....$n 脚本执行对应的第n个参数 条件判断 文件判断 test [op] path e存在 ... 
- Linux shell脚本启动 停止 重启jar包
		最近做的微服务jar包想弄在持续集成中自动化部署,所以首先得有一个操作jar包的脚本 只需将jar文件的路径替换到APP_NAME的值就可以了,其他不用改 注意:window编辑的shell文件,通过 ... 
随机推荐
- Architectural principles
			原文 "If builders built buildings the way programmers wrote programs, then the first woodpecker t ... 
- Hadoop数据类型
			hadoop包装了java的基本数据类型使他们实现以上的接口而且给予实现细节,这些类都实现了WritableComparable接口,能够在不同的hadoop节点之间毫无障碍的传输了. 
- java笔记 -- java运算
			运算符: 算术运算符: 加减乘除求余 + , - , * , / , % 当参与/运算的两个操作数都是整数时, 表示整数除法, 否则表示浮点除法. 例: 15 / 2 = 7; 15 % 2 = 1; ... 
- leecode第二百零六题(反转链表)
			/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode ... 
- Series.str——字符串批量处理方法
			针对dataframe中的某一行(或列)想做批量字符串处理时,可采用此方法 series.str.python内置的str方法 例如: series.str.replace('A','B') # ... 
- 如何使用 Deepfakes 换脸
			如何使用 Deepfakes 换脸 1. 获取deepfakes工具包 git clone https://github.com/deepfakes/faceswap.git 2. 补齐依赖包: pi ... 
- Web版记账本开发记录(四)
			今天已经是是开发软件的第四天了,今天遇到了一些简单的小问题,虽然简单,但是自己仍旧不具备修改的能力, 自己尝试了各种办法仍旧没有修改成功,在收入表就状况百出,错误不断. 我决定明天还是静下心来好好地学 ... 
- python中mysql数据库的操作-sqlalchemy
			MySQLdb支持python2.*,不支持3.* ,python3里面使用PyMySQL模块代替 python3里面如果有报错 django.core.exceptions.ImproperlyC ... 
- 另一道不知道哪里来的FFT题
			给定一个序列,求出这个序列的k阶前缀和,模998244353,n<=1e5. k阶前缀和可以看成一个一个n*k的平面上的二维行走问题. 第i项对第j项的贡献是从(i,0)走到(j,k)的NE L ... 
- 下载配置nodeJs,cnpm,webpack,vue-cli等,刚装的系统,所有东西重新配置
			最近重新装了系统,所有的环境都要重新配置了,做个笔记. 安装nodeJs: 可以参照教程:https://www.runoob.com/nodejs/nodejs-install-setup.html ... 
