• shell脚本启动java程序


    #!/bin/bash
    
    ### 切换到工作目录
    bin=$(cd `dirname ${0}`;pwd)
    cd ${bin}
    echo "bin [${bin}] .."
    
    ### 参数设置
    process="RCrNew"
    LOGPATH="/web/logs"
    day=$(date +%Y%m%d)
    #instance=$(echo ${bin}|awk -F'/' '{print $NF}')
    
    ### 如果程序已存在,先退出再执行
    #if [ $(ps -ef|grep -v grep|grep ${process}|grep ${instance}|grep -Ewv "less|tail|tailf"|wc -l) -ne 0 ]
    if [ $(ps -ef|grep -v grep|grep ${process}|grep -Ewv "less|tail|tailf"|wc -l) -ne 0 ]
    then
        ps -ef|grep -v grep|grep ${process}|grep -Ewv "less|tail|tailf"
        echo "${process} instance: ${instance} is exists,Please kill it and run agin"
        exit
    fi
    
    ### JAVA相关参数设置
    MAINCLASS="com.yyyy.app.RCNew"
    JAVA="$JAVA_HOME/bin/java"
    JAVA_OPTS="-server -Xms1024m -Xmx1024m -XX:NewSize=256m -XX:MaxNewSize=256m -XX:MaxPermSize=128m "
    JARS1=`find -L "${bin}/dependency" -name "*.jar" -printf '%p:'`
    JARS2=$(ls -rt *jar|tail -1)
    JARS=${JARS1}${JARS2}
    echo -e "JARS2: [ ${JARS2} ]
    mainClass: [ ${MAINCLASS} ]"
    # echo -e "JARS1: [ ${JARS1} ]
    JARS2: [ ${JARS2} ]
    mainClass: [ ${MAINCLASS} ]"
    # echo -e "JARS: [ ${JARS} ]"
    
    ### 执行程序
    nohup ${JAVA} ${JAVA_OPTS} -cp ${JARS} ${MAINCLASS} 1>/dev/null 2>&1 &
    if [ $? -eq 0 ]
    then
        echo "${process} run successful"
    else
        echo "${process} run fail"
    fi
    1 #!/bin/bash
    2 
    3 LIB=$(dirname ${0})
    4 echo "LIB [${LIB}] .."
    5 
    6 JARS=`find -L "${LIB}" -name '*.jar' -printf '%p:'`
    7 echo "JARS [${JARS}] .."
    8 
    9 $JAVA_HOME/bin/java -cp ${JARS} com.lxw1234.hive.orc.TestORCWriter $*
    #!/bin/bash
    VERSION=$1
    MAINCLASS=$2
    LIB=$(cd `dirname ${0}`;pwd)
    cd ${LIB}
    echo "LIB [${LIB}] .."
    
    JARS1=`find -L "${LIB}/dependency" -name "*.jar" -printf '%p:'`
    JARS2=${JARS}`find -L "${LIB}" -maxdepth 1 -name "*${VERSION}*.jar"`
    JARS=${JARS1}${JAR2}
    echo -e "JARS1: [ ${JARS1} ]
    JARS2: [ ${JARS2} ]
    mainClass: [ ${MAINCLASS} ]"
    
    $JAVA_HOME/bin/java -cp ${JARS} ${MAINCLASS} $*
  • 相关阅读:
    02.简单的DOM操作
    03.获取和设置元素特性的值
    异常为"当IDENTITY_INSERT设置为OFF时" 的解决
    GridView的RowCommand事件中取得行索引 技巧
    01.判断页面加载完成的方法
    今天新开了博客园
    C#巧用anchor和dock设计复杂界面(控件随着窗体大小的变化而变化)
    C#如何使用webbrowser控件制作一个简易的IE浏览器(菜鸟级)
    断箭——不相信自己的意志,永远也做不成将军
    成长与成功
  • 原文地址:https://www.cnblogs.com/chenzechao/p/9202094.html
Copyright © 2020-2023  润新知