===============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. JavaScript(数据类型、字符串操作)

    JS基础 建议:一般情况下不在 head 标签中写 js 语句,因为该 js 语句会在 body 加载之前就执行,可能导致某些效果无效 // 单行注释 /*多行 * 注释*/ // 控制台输出语句 c ...

  2. Vnpy二次开发应用所需图标

    在针对Vnpy二次开发时,很多窗口中需要使用到“小图标” 给大家分享一个UI的专业图标网,上面资源齐全. https://www.iconfont.cn/collections?personal=1

  3. guxh的python笔记六:类的属性

    1,私有属性 class Foo: def __init__(self, x): self.x = x 类的属性在实例化之后是可以更改的: f = Foo(1) print(f.x) # 1 f.x ...

  4. springcloud-Ribbon-负载均衡组件

    Ribbon负载均衡 1.Ribbon简介 ribbin是Netflix发布的负载均衡器,有助于控制http和tcp客户端的行为,为ribbon配置服务提供者列表后,ribbon就可以基于某种负载均衡 ...

  5. 单机器搭建 zk 集群

    在一台机器上配置 2 节点的 zk 集群,zk1 和 zk2 的 serverid 分别为 1 和 2,本机 ip 是 192.168.40.1 zk1 相关配置: dataDir=E:/test/z ...

  6. protobuf example make backup

    # See README.txt. .PHONY: all cpp java python clean all: cpp #java python cpp: add_person_cpp list_p ...

  7. serial front_door signment and gps signment

    import socketimport serialimport osimport sysimport struct#serial ser_intf = serial.Serial(port='/de ...

  8. Linux---centos编译安装ffmpeg

    环境 系统环境:CentOS release 6.7 (Final) 需求 编译安装ffmpeg 获取依赖 安装依赖包 yum install -y autoconf automake cmake f ...

  9. 超简单的实现wordcount

    worcount1.0,源码参见GitHub:https://github.com/18382271904/spring_lee_flag.git

  10. oracle with和insert结合使用

    需求是这样的,先在一个从句中根据sub_code查询dis_code和reg_code, 再把这:两个值作为insert value的一部分,差到rate表里,好了,这里提供一种常规做法,和一种用wi ...