zoukankan      html  css  js  c++  java
  • Shell常用操作

    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$1
    APP_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 end
    
    
    
    
    jsDir=`pwd`
    ps -ef|grep 19393|grep -v "grep"|awk '{print $2}'|xargs kill -9
    
    
    
    
    DOWNTIME=`date +%Y/%m/%d" "%A" "%H:%M:%S`
    echo -e "
    
    app shutdown-time is: $DOWNTIME 
    
    " >>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_HOME
    fi
    
    if [ -z "$JETTY_HOME" ] ; then
        if [ -n "$BINDIR" ] ; then
            JETTY_HOME=`cd $BINDIR > /dev/null 2>&1 && pwd`
            export JETTY_HOME
        fi
    fi
    
    # set JAVA_HOME variable here.
    #JAVA_HOME=/usr/local/test/jdk1.5.0_22
    
    if [ -n "$JAVA_HOME"  ] ; then
        JAVA_RUN=$JAVA_HOME/bin/java
        export JAVA_HOME
    else
        JAVA_RUN=`which java 2> /dev/null `
        if [ -z "$JAVA_RUN" ] ; then
            JAVA_RUN=java
        fi
    fi
    
    #set jetty start options
    JETTY_PORT=19393
    JETTY_OPTS="-DSTOP.PORT=$JETTY_PORT -DSTOP.KEY=secret"
    JETTY_RUN="tail -f nohup.out"
    
    #set product name for app
    PRODUCT_NAME=app
    
    export JAVA_RUN
    export PATH="$JETTY_HOME/bin:$PATH"
    
    #decide yacs status
    #return 0 represent YACS is running
    #return 1 represent YACS is not running
    yacs_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.sh
    sleep 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;
    EOF
    
    echo " end create mysql userdatabase "
    }
  • 相关阅读:
    在安装ODAC后再安装.netframework导致应用程序无法找到.netframework data provider的解决方案(3种)
    浅谈Scrum敏捷开发:4个输入/输出、3个关键物、3个会议
    Payoneer个人账户注册申请教程
    巧用netsh命令实现端口转发(端口映射)不求人
    京东也开始欺骗消费者了
    powershell解决win10开始菜单和通知中心无法打开
    有些其他程序设置为从 Outlook 下载并删除邮件。为防止发生此意外情况,我们将这些邮件放入一个特殊的 POP 文件夹中
    maven搭建
    java面试第四弹(算法和编程)思路
    每秒处理10万高并发订单的乐视集团支付系统架构分享
  • 原文地址:https://www.cnblogs.com/huige-you/p/4380708.html
Copyright © 2011-2022 走看看