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。

posted @ 2017-08-10 18:48  叶落之秋  阅读(606)  评论(0编辑  收藏  举报