首页 > 代码库 > shell脚本实战
shell脚本实战
想写个脚本,发现都忘了,蛋疼,一边回忆一边查一边写,总算完成了,贴在下面:
1 #!/bin/bash 2 #Program: 3 # This program can help you quickly redeploy the project 4 #History: 5 # 2017/08/10 shichaogeng First release 6 7 #variable 8 jar_file="usp-lm-1.1.4.jar" 9 project="usp-lm" 10 project_path_prefix="/alidata/projects/" 11 project_path_midfix="/Atomcat/webapps/" 12 project_path_suffix="/WEB-INF/lib" 13 source_path="/alidata/source_code/" 14 15 #accept the parameters 16 if [ ! -n "${1}"]; then 17 jar_file="${1}" 18 fi 19 if [ ! -n "${2}"]; then 20 project="${2}" 21 fi 22 23 #judge if exist 24 if [ ! -f "$source_path$jar_file" ]; then 25 echo "The jar is not exist in the path $source_path" 26 fi 27 if [ ! -d "$project_path_prefix$project" ]; then 28 echo "The project is not exist in the path $project_path_prefix" 29 fi 30 31 #ready 32 cd $project_path_prefix$project$project_path_midfix$project$project_path_suffix 33 rm -rf $jar_file 34 cp $source_path$jar_file ./ 35 cd $project_path_prefix$project/Atomcat 36 pid=$(ps x | grep "usp-lm" | grep -v grep | awk ‘{print $1}‘) 37 kill -9 $pid 38 rm -rf logs/* 39 rm -rf work/* 40 41 #restart 42 ./bin/startup.sh 43 tail -f logs/catalina.out
写这么个玩意弄了一小时,笑cry。
shell脚本实战
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。