Shell script to start the program

Source: Internet
Author: User

We all know that the JVM itself provides a lot of commands for users to call. Sometimes we need to use these commands to write some scripts to execute our program. First, let's talk about the directory structure of the following script:

  • Bin script Storage

  • Lib dependent jar package Storage

  • Configuration file storage on which conf depends

  • Run the prepared JAR file in the current directory.

#!/bin/bashexport JAVA_HOME=/usr/javaexport PATH=$JAVA_HOME/bin:$PATH#-------------------------------------------------------------------#    Mb Bootstrap Script #-------------------------------------------------------------------function main(){    # find Mb home.    CURR_DIR=`pwd`    cd `dirname "$0"`/..    RESV_HOME=`pwd`    cd $CURR_DIR    if [ -z "$RESV_HOME" ] ; then        echo        echo Must set RESV_HOME        echo        exit 1    fi    pc=`ps -ef | grep "ThreadMore $1" | wc -l `    echo "process count:$pc"    if [[ $pc -gt 1 ]];        then        echo "last job havent finish,exit."        exit 1    fi    execute $1 $2}function execute(){    for i in $RESV_HOME/lib/*.jar; do         CLASSPATH=$i:$CLASSPATH;          done     #echo RESV_HOME=$RESV_HOME    CLASSPATH=$RESV_HOME/conf:$RESV_HOME/smack.jar:$CLASSPATH    DEBUG_INFO=" -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n"    DEBUG=""    if [ "$1" = "load" ]    then         MAIN_CLASS="www.smack.ThreadLocal $1";         DEFAULT_OPTS="-server -Xms10G -Xmx10G " ;    else        if [ "$1" = "check" ]        then            MAIN_CLASS="www.smack.ThreadLocal ";            DEFAULT_OPTS="-server -Xms2G -Xmx2G" ;        else             MAIN_CLASS="www.smack.ThreadLocal $1 $2";            DEFAULT_OPTS="-server -Xms2000m -Xmx2000m -Xss128k" ;        fi    fi    DEFAULT_OPTS="$DEFAULT_OPTS -Djava.awt.headless=true -Dcom.sun.management.jmxremote.port=9999 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Djava.rmi.server.hostname=10.10.10.7"    DEFAULT_OPTS="$DEFAULT_OPTS  -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=60"    DEFAULT_OPTS="$DEFAULT_OPTS -DMB.home=\"$RESV_HOME\""    echo java $DEBUG $DEFAULT_OPTS  -classpath $CLASSPATH  $MAIN_CLASS    java $DEBUG $DEFAULT_OPTS  -classpath $CLASSPATH  $MAIN_CLASS}main "4000" "40"


This article from the "Chen Yan Xi" blog, please be sure to keep this source http://chenyanxi.blog.51cto.com/4599355/1559651

Shell script to start the program

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.