1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
| #!/bin/bash # #
day=`date +'%Y-%m-%d'` anynowtime="date +'%Y-%m-%d %H:%M:%S'" NOW="echo [\`$anynowtime\`][PID:$$]"
# #function job_start job_start() { echo "`eval $NOW` job_start" }
# job_success() { MSG="$*" echo "`eval $NOW` job_success:[$MSG]" # exit 0 }
# job_fail() { MSG="$*" echo "`eval $NOW` job_fail:[$MSG]" exit 1 }
job_start
# job_shell() { case "$1" in 0) nohup java -Xms1024m -Xmx2048m -jar /bright/apps/file.jar >> /bright/apps/out/$day-file.log 2>&1 & if [ $? -eq 0 ] ; then job_success "$*" tail -fn 50 /apps/out/$day-file.log exit 0 else job_fail "$*" fi ;; 1) kill -15 `ps -ef|grep /bright/apps/file.jar |grep -v grep|awk '{print $2}'` if [ $? -eq 0 ] ; then job_success "$*" else job_fail "$*" fi ;; 2) kill -9 `ps -ef|grep /bright/apps/file.jar |grep -v grep|awk '{print $2}'` if [ $? -eq 0 ] ; then sleep 3 nohup java -Xms1024m -Xmx2048m -jar /bright/apps/file.jar >> /bright/apps/out/$day-file.log 2>&1 & if [ $? -eq 0 ] ; then job_success "$*" tail -fn 50 /bright/apps/out/$day-file.log exit 0 else job_fail "$*" fi else job_fail "$*" fi ;; *) echo "Usage: $0 {0[start]|1[stop]|2[restart]}" exit 1 esac exit 0 } # #
read -r -p "Please input name:" name read -r -p "Please input pawd:" pawd # echo "you have entered $name, $pawd" if [ "$name" = "jwgod" ] || [ "$pawd" = "jwgod" ] ; then # echo -e "\033[32myou have entered $name, $pawd\033[0m" echo -e "\033[32请选择要执行的操作 {0[start]|1[stop]|2[restart]|3[file----html]}\033[0m" read -r -p "你选择的操作是:" exec_sh if [ $exec_sh == 3 ];then rm -rf /bright/apps/h5/dist unzip -o /bright/apps/dist.zip -d /bright/apps/h5/ if [ $? -eq 0 ] ; then job_success "$*" else job_fail "$*" fi else # echo -e "\033[32请选择要执行的操作 $exec_sh\033[0m" job_shell "$exec_sh" fi else exit 1 fi
|