===============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. 同事在使用shiro后遇到的异常

    一切配置按照demo来的,给他讲了一遍捋顺了.然后之前他做的demohim按照他网络摘抄的shiro博客看的. 然后注册了,正常,登录,提示密码不匹配. 问题出在注册的密码加密次数是2, 而shiro ...

  2. IdentityServer4 错误解决方案

    错误 解决方案 Grant types list cannot contain both xx and xx 以下授权类型不能同时存在: Implicit AuthorizationCode Impl ...

  3. C#关于多线程及线程同步 lock锁的应用

    Form1.cs using System; using System.Collections.Generic; using System.ComponentModel; using System.D ...

  4. js 过滤器

    ,,]; ary[] = ; ary.filter(function(x) { return x === undefined; }); // A. [undefined x 7] // B. [0, ...

  5. leecode第二百一十五题(数组中的第K个最大元素)

    class Solution { public: int quick_sort_version(vector<int>& nums, int k,int begin,int end ...

  6. 二叉树分派硬币 Distribute Coins in Binary Tree

    2019-03-27 15:53:38 问题描述: 问题求解: 很有意思的题目.充分体现了二叉树的自底向上的递归思路. 自底向上进行运算,对于最底层的二叉子树,我们需要计算每个节点向其parent传送 ...

  7. mysql数据库通过二进制 -【恢复数据记录】

    1.修改配置文件 vi /etc/my.cnf log-bin = binlog systemctl restart mysqld mysql -uroot -p123456 mysql> sh ...

  8. CentOS7配置httpd虚拟主机

    本实验旨在CentOS7系统中,httpd-2.4配置两台虚拟主机,主要有以下要求: (1) 提供两个基于名称的虚拟主机: www1.stuX.com,页面文件目录为/web/vhosts/www1: ...

  9. 精确率、准确率、召回率和F1值

    当我们训练一个分类模型,总要有一些指标来衡量这个模型的优劣.一般可以用如题的指标来对预测数据做评估,同时对模型进行评估. 首先先理解一下混淆矩阵,混淆矩阵也称误差矩阵,是表示精度评价的一种标准格式,用 ...

  10. Wincc用户登录VBS脚本

    在Wincc中为防止未知用户的误操作,在操作性按钮以及图符等设备操作面板,在组流程图时,需设置用户权限,只有符合权限的用户才可以进行操作.所以在流程图界面需设置系统用户登录界面.登录操作可以选择按钮或 ...