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文件,通过 ...
随机推荐
- MySQL安装指南(转)
MySQL安装指南 安装MySQL sudo apt-get install mysql-server 这个应该很简单了,而且我觉得大家在安装方面也没什么太大问题,所以也就不多说了,下面我们来讲讲 ...
- Qt获取选择的文件夹和文件路径
获取文件夹路径 static QString getExistingDirectory(QWidget *parent = Q_NULLPTR, const QString &caption ...
- Yarn 踩坑 : Could not find or load main class org.apache.hadoop.mapreduce.v2.app.MRAppMaster
原因:yarn-site.xml 中,yarn.application.classpath 未配置 解决:其中 hadoop 版本对应更改 <property> <name>y ...
- DateHelper
public static class DateHelp { /// <summary> /// 获取当前日期是该月的第几周 /// </summary> /// <pa ...
- pytest文档14-函数传参和firture传参数request
前言 为了提高代码的复用性,我们在写用例的时候,会用到函数,然后不同的用例去调用这个函数. 比如登录操作,大部分的用例都会先登录,那就需要把登录单独抽出来写个函数,其它用例全部的调用这个登陆函数就行. ...
- CAM(Content Addressable Memory)介绍
CAM是一种特殊的存储器.所谓CAM,即内容寻址存储器.CAM存储器在其每个存储单元都包含了一个内嵌的比较逻辑,写入CAM的数据会和其内部存储的每一个数据进行比较,并返回与端口数据相同的所有内部数据的 ...
- 各大型网站架构分析收集-原网址http://blog.csdn.net/lovingprince/article/details/3379710
1. PlentyOfFish 网站架构学习http://www.dbanotes.net/arch/plentyoffish_arch.html 采取 Windows 技术路线的 Web 2.0 站 ...
- n阶楼梯,一次走1,2,3步,求多少种不同走法
##已知n阶楼梯,一次可以迈1,2,3步.求所有走法## 如果要列出走法,时间复杂度太高,O(n)=2**n,前两个函数遍历走法.## 如果只是单纯列出走法数量,就简单多了,也但是很容易内存爆表. # ...
- php加密
域名授权函数 function allow_doamin(){ $is_allow=false; $url=trim($_SERVER['SERVER_NAME']); $arr_a ...
- Ubuntu系统下安装免驱动摄像头
最近想玩一下视频系列的深度学习模型,便网上淘了一个linux下免驱动的摄像头,直接插上usb接口就行,但是一般还不能直接使用,下面将简单说一下如何使用摄像头: 在你的ternimal下输入以下命令: ...