Linux-查找對應的服務與JDK安裝

 查找對應的服務並執行相關命令

 

#!/bin/bash
source ~/.bashrc
echo ">>>腳本位置:$0"
echo ">>>任務參數:$1"
SERVER_NAME=test
if [ -n "$1" ]; then
 SERVER_NAME=$1
fi
echo "The serverName is $SERVER_NAME"
PIDS=$(ps -aux |grep home| grep $SERVER_NAME |awk '{print $2}')

## 是否查找到對應的服務
if [ -n "$PIDS" ]
 then
    echo "The $SERVER_NAME $PIDS is running!"
    echo "killing..."
    sudo kill -9 $PIDS
    echo "The $SERVER_NAME $PIDS already killed!"
 else
    echo "The server $SERVER_NAME is not running"
fi

## 如果參數 SERVER_NAME 指定爲"test"服務
if [ "$SERVER_NAME" == "test" ]; then
  sudo rm -rf /home/apps/test-server/
  sudo cp /home/test/test-server-release.tar.gz /home/apps/test-server-release.tar.gz
  sudo tar -xvf /home/apps/test-server-release.tar.gz -C /home/apps/
  ll /home/apps
  ## 切換work用戶,執行start.sh
  nohup sudo su - work -s /home/apps/test-server/bin/start.sh jmx >/home/test/nohup.out 2>&1 &
  tail -50f /data/logs/test/stdout.log
fi

JDK安裝

wget後加上 --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" 就可以了,如:

wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u191-b12/2787e4a523244c269598db4e85c51e0c/jdk-8u191-linux-x64.tar.gz

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章