码迷,mamicode.com
首页 > 系统相关 > 详细

shell脚本实战

时间:2017-08-10 20:50:52      阅读:218      评论:0      收藏:0      [点我收藏+]

标签:work   atom   webapps   rm -rf   tar   res   accept   shel   color   

想写个脚本,发现都忘了,蛋疼,一边回忆一边查一边写,总算完成了,贴在下面:

 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脚本实战

标签:work   atom   webapps   rm -rf   tar   res   accept   shel   color   

原文地址:http://www.cnblogs.com/gengsc/p/7340894.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!