===============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的更多相关文章

  1. 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 ...

  2. Linux Systemd——在RHEL/CentOS 7中启动/停止/重启服务

    RHEL/CentOS 7.0中一个最主要的改变,就是切换到了systemd.它用于替代红帽企业版Linux前任版本中的SysV和Upstart,对系统和服务进行管理.systemd兼容SysV和Li ...

  3. 在CentOS 7中启动/停止/重启服务

    RHEL/CentOS 7.0中一个最主要的改变,就是切换到了systemd.它用于替代红帽企业版Linux前任版本中的SysV和Upstart,对系统和服务进行管理.systemd兼容SysV和Li ...

  4. linux如何启动/停止/重启MySQL

    如何启动/停止/重启MySQL 一.启动方式 1.使用 service 启动:service mysqld start2.使用 mysqld 脚本启动:/etc/inint.d/mysqld star ...

  5. 批处理命令行CMD启动停止重启IIS的命令

    原文:批处理命令行CMD启动停止重启IIS的命令 启动IIS: net start iisadmin    (IIS的整个服务) net start w3svc       (WWW网页WEB服务) ...

  6. Linux编辑启动停止重启springboot jar包脚本

    springboot的配置文件中,配置文件的名字都有各自的意义跟用途 dev 开发环境 prod 生产环境(默认) test 测试环境 加载指定配置文件 --spring.profiles.activ ...

  7. .xxx.sh脚本无法启动,原来都是特殊字符搞的鬼?

    今天遇到个趣的问题,linux上springboot启动,连接达梦数据库报错. 解决思路: 1)是不是数据库本身有问题,客户端登录没问题. 2)排查是不是war包问题,本地连接数据库,没问题. 3)是 ...

  8. sh脚本学习之: sh脚本 、sed、awk

    sh脚本 sh命令的批处理文件,支持更复杂的逻辑. Shell中的变量 参数 $0 当前脚本路径 $1....$n 脚本执行对应的第n个参数 条件判断 文件判断 test [op] path e存在 ...

  9. Linux shell脚本启动 停止 重启jar包

    最近做的微服务jar包想弄在持续集成中自动化部署,所以首先得有一个操作jar包的脚本 只需将jar文件的路径替换到APP_NAME的值就可以了,其他不用改 注意:window编辑的shell文件,通过 ...

随机推荐

  1. Importing Maven projects' has encountered a problem

    导入项目是报错,这个是maven问题--Importing Maven projects' has encountered a problem ---------------------------- ...

  2. C# --- ??(空接合操作符)的一个案例

    Nullable<Int32> x = null; Nullable<Int32> y = null; Nullable<Int32> z = null; Int3 ...

  3. Family 科

    拉丁语 familia 目--> 总科-->科-->亚科(亚科的拉丁文分类滋味通常是-inae) [族] 属

  4. fabric网络环境启动过程详解

    这篇文章对fabric的网络环境启动过程进行讲解,也就是我们上节讲到的启动测试fabric网络环境时运行network_setup.sh这个文件的执行流程 fabric网络环境启动过程详解 上一节我们 ...

  5. Qt-Designer打不开

    安装Qt后双击桌面的Designer没有反应,解决办法就是将安装路径里的qwebengineview.dll文件后缀名加个".bak".

  6. linux 程序无缘无故推出 没有core文件 broken pipe Resource temporarily unavailable

    问题 1. linux socket 服务端程序 无缘无故退出 . 2. 客户端大量访问服务端后,出现  Resource temporarily unavailable错误 问题分析: 1. 是否有 ...

  7. Ubuntu安装vsftpd并通过xftp连接

    1.在ubuntu中安装xftp: sudo apt-get update sudo apt-get install vsftpd sudo service vsftpd restart 2.防火墙添 ...

  8. 超恶心的TP模版取值

    一.JS事件中 在使用H-uiAdmin做后台开发的时候,碰到了使用元素点击触发js函数展示弹窗的写法 但是在js函数中还需要使用U函数生成url以及使用$vo.id来传值 反复试了一下模版标签的写法 ...

  9. Forth词典条目结构

    body, table{font-family: 微软雅黑} table{border-collapse: collapse; border: solid gray; border-width: 2p ...

  10. github的优势

    1.GitHub作为托管平台只支持git版本库托管而不像其他开源项目托管平台还对CVS.SVN.Hg 等格式的版本库进行托管.GitHub 的哲学很简单,既然 Git 是最好的版本控制系统之一(对于很 ...