远程上线脚本
客户端脚本:#!/bin/bashecho -e "\033[32m 命令介绍如下:\033[0m"echo 'backup : 备份'echo 'start : 启动'echo 'restart : 重启'echo 'stop : 停止'echo 'rsync : 同步'echo 'rollback : 回滚'read -p "请输入要同步的命令: " commandif [ "$command" == "" ];thenecho "请输入你要进行的操作:{backup start stop restart rsync rollback }"elif ([ "$command" != "start" ] && [ "$command" != "stop" ] && [ "$command" != "restart" ] && [ "$command" != "backup" ] && [ "$command" != "rsync" ] && [ "$command" != "rollback" ]);thenecho "请输入你要进行的操作:{backup start stop restart rsync rollback }"elif([ "$command" == "rsync" ]);thenread -p "请输入要同步到的服务器ip地址: " ipread -p "请输入要同步到的文件名称: " file_nameecho $file_name/usr/bin/rsync -avzogP --stats --progress --include="$file_name" --exclude="/*" --password-file=/usr/local/rsync/backup.secrets /usr/local/tomcat/webapps/ rsync@$ip::webappselseecho "/home/www/tomcat_m_20021 $command" > /usr/local/tomcat/commandread -p "请输入要同步到的服务器ip地址: " ip/usr/bin/rsync -avzogP --stats --progress --password-file=/usr/local/rsync/backup.secrets --include='command' --exclude='/*' /usr/local/tomcat/ rsync@$ip::rsyncfi线上脚本如下:(但是要开启定时任务,不挺扫描客户端的请求)#!/bin/shCommand_file="/usr/local/tomcat/command"Project_name=`cat $Command_file |awk '{print $1}'`Command=`cat $Command_file |awk '{print $2}'`my_Back="webapps_backup"echo $Commandif [ -n "$Command" ];thencase "$Command" instart)export JAVA_HOME=/usr/local/java/jdk1.6.0_23cd $Project_namerm -rf work/*$Project_name/bin/startup.sh`/bin/cat /dev/null >$Command_file`sleep 3/usr/bin/tail -1000 $Project_name/logs/catalina.outecho -e "\033[32m启动成功\033[0m";;stop)pidlist=`ps -ef|grep $Project_name|grep -v "grep" |awk '{print $2}'`echo "tomcat Id list :$pidlist"kill -15 $pidlistecho "KILL $pidlist:"sleep 30tompid=`ps -ef|grep $Project_name|grep -v "grep" |awk '{print $2}'`if ( [ -n "$tompid" ] && [ $tompid == $pidlist ] );thenecho -e "\033[31m停止失败,请重新执行一次命令\033[0m"`/bin/cat /dev/null >$Command_file`elseecho -e "\033[32m停止成功\033[0m"`/bin/cat /dev/null >$Command_file`fi;;restart)export JAVA_HOME=/usr/local/java/jdk1.6.0_23pidlist=`ps -ef|grep $Project_name|grep -v "grep"|awk '{print $2}'`echo "tomcat Id list :$pidlist"kill -15 $pidlistecho "KILL $pidlist:"echo "stop success"echo "start tomcat"cd $Project_namerm -rf work/*cd bin./startup.sh`/bin/cat /dev/null >$Command_file`sleep 3/usr/bin/tail -1000 $Project_name/logs/catalin补充:综合编程 , 其他综合 ,
上一个:IE CSS hack
下一个:截图工具离线版文档