Shell常用操作

來源:互聯網
上載者:User

標籤:

1、讀取設定檔中的jdbc_url參數的值($InputParamFile為待讀取的目標檔案絕對路徑)

jdbc_url=`grep "jdbc_url" $InputParamFile | awk -F ‘=‘ ‘{print $2}‘`

2、修改設定檔jdbc_url參數的值(${jdbcConfigFilePath}為待修改的目標檔案絕對路徑)

sed -i "s#\${jdbc_url}#${jdbc_url}#" ${jdbcConfigFilePath}

3、啟動Jetty指令碼

JETTY_PORT=1$1APP_HOME=`pwd`app_status() {        port=`ps -aef | grep STOP.PORT=19393 | sed -n ‘1p‘ | awk ‘{if($8~/java/)print $9}‘ | awk -F= ‘{print $2}‘`             if [ -z $port ] ; then                return 1        fi        if [ "$port" == "$JETTY_PORT" ] ; then                return 0        else                return 1        fi}if app_status ; then     echo "app is running now....."else    java -DSTOP.PORT=$JETTY_PORT -Djava.net.preferIPv4Stack=true -server -Xms1G -Xmx1G -Xmn256M -XX:PermSize=256M -XX:MaxPermSize=256M  -XX:SurvivorRatio=32 -XX:MaxTenuringThreshold=3 -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:+UseCMSCompactAtFullCollection -XX:CMSFullGCsBeforeCompaction=0 -XX:+CMSClassUnloadingEnabled -XX:-CMSParallelRemarkEnabled -XX:CMSInitiatingOccupancyFraction=90 -XX:SoftRefLRUPolicyMSPerMB=0 -Djava.util.logging.config.file="$YACS_HOME/yacs/conf/log4j.xml" -jar start.jar & fi

4、停止Jetty指令碼

#$JAVA_RUN $JETTY_OPTS -jar start.jar --stop#  del by xxx endjsDir=`pwd`ps -ef|grep 19393|grep -v "grep"|awk ‘{print $2}‘|xargs kill -9DOWNTIME=`date +%Y/%m/%d" "%A" "%H:%M:%S`echo -e "\n\napp shutdown-time is: $DOWNTIME \n\n" >>app/log/error/app-error.log

5、查看Jetty運行狀態

#!/bin/sh## All Rights Reserved# -------------------------------------------------------------------------------# Environment Variable Prequisites Before Start/Stop Script for the Jetty Server##   JETTY_HOME      May point at your jetty setup directory.##   JAVA_HOME       Must point at your Java Development Kit installation.#                   Required to run the with the "debug" or "javac" argument.##   JRE_HOME        Must point at your Java Development Kit installation.#                   Defaults to JAVA_HOME if empty.##   JETTY_PORT      Must point at your jetty stop port, when you start jetty server.##   JAVA_OPTS       (Optional) Java runtime options used when the "start",#                   "stop", or "run" command is executed.##   JETTY_RUN       (Optional) output terminal when to start jetty server.##   JPDA_OPTS       (Optional) Java runtime options used when the "jpda start"#                   command is executed. If used, JPDA_TRANSPORT, JPDA_ADDRESS,#                   and JPDA_SUSPEND are ignored. Thus, all required jpda#                   options MUST be specified. The default is:##                   -agentlib:jdwp=transport=$JPDA_TRANSPORT,#                       address=$JPDA_ADDRESS,server=y,suspend=$JPDA_SUSPEND##   JETTY_OPTS      Must point at when to start jetty server, which can show jetty #                   stop port.# ---------------------------------------------------------------------------------BINDIR=`dirname $0`if [ -n "$BINDIR" ] ; then    JETTY_HOME=`cd $BINDIR > /dev/null 2>&1 && pwd`    export JETTY_HOMEfiif [ -z "$JETTY_HOME" ] ; then    if [ -n "$BINDIR" ] ; then        JETTY_HOME=`cd $BINDIR > /dev/null 2>&1 && pwd`        export JETTY_HOME    fifi# set JAVA_HOME variable here.#JAVA_HOME=/usr/local/test/jdk1.5.0_22if [ -n "$JAVA_HOME"  ] ; then    JAVA_RUN=$JAVA_HOME/bin/java    export JAVA_HOMEelse    JAVA_RUN=`which java 2> /dev/null `    if [ -z "$JAVA_RUN" ] ; then        JAVA_RUN=java    fifi#set jetty start optionsJETTY_PORT=19393JETTY_OPTS="-DSTOP.PORT=$JETTY_PORT -DSTOP.KEY=secret"JETTY_RUN="tail -f nohup.out"#set product name for appPRODUCT_NAME=appexport JAVA_RUNexport PATH="$JETTY_HOME/bin:$PATH"#decide yacs status#return 0 represent YACS is running#return 1 represent YACS is not runningyacs_status() {    port=`ps -aef | grep STOP.PORT=$JETTY_PORT | sed -n ‘1p‘ | awk ‘{if($8~/java/)print $9}‘ | awk -F= ‘{print $2}‘`    echo $port    if [ -z $port ] ; then        return 1     fi            if [ "$port" == "$JETTY_PORT" ] ; then        return 0     else         return 1     fi}

6、重啟Jetty

./stopiuc.shsleep 10./startiuc.sh

7、匯入MySQL資料

installorupdatemysql(){if [ $reBuilddDB == "N" ];then  return ;fi    echo " start create mysql userdatabase "    # 匯入資料    cd $install_home/SQL/Mysql/Install        mysql -uroot -p$password << EOF    source 00_create_user.sql;    use app;    source 01_app_install.sql;EOFecho " end create mysql userdatabase "}

 

Shell常用操作

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.