手中一个项目,频繁更新,备份和重启服务脚本
#!/bin/bash #易通贷测试环境更新备份脚本 #脚本使用说明 if [ $# -lt 2 ] then echo "-------------------------------------------------" echo "+执行脚本 应用名称 需要备份的目录(目录可为多个)+" echo "-------------------------------------------------" echo -e ‘\033[0;31;1m输入错误,请重新输入\033[0m‘ exit 0 fi #项目代码路径 portal_path=‘/home/tomcat/tomcat-7.0.52-p2p-portal/wtpwebapps/p2p-portal/‘ platform_path=‘/home/tomcat/tomcat-7.0.52-p2p-platform/wtpwebapps/p2p-platform/‘ crm_path=‘/home/tomcat/tomcat-7.0.52-p2p-crm/wtpwebapps/p2p-crm/‘ news_path=‘/home/tomcat/tomcat-7.0.52-p2p-news/wtpwebapps/p2p-news/‘ schedule_path=‘/home/tomcat/tomcat-7.0.52-p2p-schedule/wtpwebapps/p2p-schedule/‘ server_path=‘/home/tomcat/tomcat-7.0.52-p2p-server/wtpwebapps/p2p-server/‘ weixin_path=‘/home/tomcat/tomcat-7.0.52-p2p-server/wtpwebapps/p2p-weixin/‘ sms_path=‘/home/tomcat/tomcat-7.0.52-p2p-sms/webapps/seaway_sms/‘ task_path=‘/home/tomcat/tomcat-7.0.52-p2p-task/wtpwebapps/p2p-task‘ #备份路径 backup_path=‘/home/jiachen/backup/‘ #时间变量 date=`date +"%Y%m%d"` #生成当天备份总目录 cd ${backup_path} if [ ! -e ${date} ] then mkdir -pv ${date} fi #生成要备份的目录 cd ${date} new_backup_path=`date +"%H_%M"` && mkdir -pv ${new_backup_path} #备份 cd ${new_backup_path} case $1 in portal) for i in `seq 2 1 $#` do eval cp -a ${portal_path}\${$i} ./ done ;; platform) for i in `seq 2 1 $#` do eval cp -a ${platform_path}\${$i} ./ done ;; crm) for i in `seq 2 1 $#` do eval cp -a ${crm_path}\${$i} ./ done ;; news) for i in `seq 2 1 $#` do eval cp -a ${news_path}\${$i} ./ done ;; schedule) for i in `seq 2 1 $#` do eval cp -a ${schedule_path}\${$i} ./ done ;; server) for i in `seq 2 1 $#` do eval cp -a ${server_path}\${$i} ./ done ;; weixin) for i in `seq 2 1 $#` do eval cp -a ${weixin_path}\${$i} ./ done ;; sms) for i in `seq 2 1 $#` do eval cp -a ${sms_path}\${$i} ./ done ;; task) for i in `seq 2 1 $#` do eval cp -a ${task_path}\${$i} ./ done ;; *) echo -e ‘\033[0;31;1m输入应用名错误,请重新输入\033[0m‘ exit 0 ;; esac # if [ $? -eq 0 ] then echo -e ‘\033[0;32;1m备份完成\033[0m‘ fi exit 0
#!/bin/bash #启动、停止应用脚本 #显示菜单 echo ‘1-stop portal 2-start portal‘ echo ‘3-stop platform 4-start platform‘ echo ‘5-stop crm 6-start crm‘ echo ‘7-stop news 8-start news‘ echo ‘9-stop schedule 10-start schedule‘ echo ‘11-stop server 12-start server‘ echo ‘13-stop sms 14-start sms‘ echo ‘15-stop task 16-start task‘ #选择编号 read -p ‘请输入要选择的变化:‘ choice #应用pid portal_pid=`ps -ef |grep java|grep portal|awk ‘{print $2}‘` platform_pid=`ps -ef |grep java|grep platform|awk ‘{print $2}‘` crm_pid=`ps -ef |grep java|grep crm|awk ‘{print $2}‘` news_pid=`ps -ef |grep java|grep news|awk ‘{print $2}‘` schedule_pid=`ps -ef |grep java|grep schedule|awk ‘{print $2}‘` server_pid=`ps -ef |grep java|grep server|awk ‘{print $2}‘` sms_pid=`ps -ef |grep java|grep sms|awk ‘{print $2}‘` task_pid=`ps -ef |grep java|grep task|awk ‘{print $2}‘` if [ $choice -eq 1 ] then kill -9 $portal_pid echo "portal 已停止" elif [ $choice -eq 2 ] then /home/tomcat/tomcat-7.0.52-p2p-portal/bin/startup.sh echo "portal 已启动" elif [ $choice -eq 3 ] then kill -9 $platform_pid echo "platform 已停止" elif [ $choice -eq 4 ] then /home/tomcat/tomcat-7.0.52-p2p-platform/bin/startup.sh echo "platform 已启动" elif [ $choice -eq 5 ] then kill -9 $crm_pid echo "crm 已停止" elif [ $choice -eq 6 ] then /home/tomcat/tomcat-7.0.52-p2p-crm/bin/startup.sh echo "crm 已启动" elif [ $choice -eq 7 ] then kill -9 $news_pid echo "news 已停止" elif [ $choice -eq 8 ] then /home/tomcat/tomcat-7.0.52-p2p-news/bin/startup.sh echo "news 已启动" elif [ $choice -eq 9 ] then kill -9 $schedule_pid echo "schedule 已停止" elif [ $choice -eq 10 ] then /home/tomcat/tomcat-7.0.52-p2p-schedule/bin/startup.sh echo "schedule 已启动" elif [ $choice -eq 11 ] then kill -9 $server_pid echo "server 已停止" elif [ $choice -eq 12 ] then /home/tomcat/tomcat-7.0.52-p2p-server/bin/startup.sh echo "server 已启动" elif [ $choice -eq 13 ] then kill -9 $sms_pid echo "sms 已停止" elif [ $choice -eq 14 ] then /home/tomcat/tomcat-7.0.52-p2p-sms/bin/startup.sh echo "sms 已启动" elif [ $choice -eq 13 ] then kill -9 $task_pid echo "task 已停止" elif [ $choice -eq 14 ] then /home/tomcat/tomcat-7.0.52-p2p-task/bin/startup.sh echo "task 已启动" else echo "输入错误" fi
时间: 2024-11-06 07:40:26