`CUR_SHELL_DIR=`pwd`CUR_SHELL_NAME=`basename ${BASH_SOURCE}`#修改这里jar包名即可"og:type" content="webpage">`CUR_SHELL_DIR=`pwd`CUR_SHELL_NAME=`basename ${BASH_SOURCE}`#修改这里jar包名即可" /> `CUR_SHELL_DIR=`pwd`CUR_SHELL_NAME=`basename ${BASH_SOURCE}`#修改这里jar包名即可"> java调用shell脚本_java调用shell脚本传参数_投稿_内存溢出

阅读 49

java调用shell脚本_java调用shell脚本传参数,第1张

java调用shell脚本_java调用shell脚本传参数

一个通用的java应用程序启动shell脚本:#!/bin/bashcd `dirname $0`CUR_SHELL_DIR=`pwd`CUR_SHELL_NAME=`basename ${BASH_SOURCE}`#修改这里jar包名即可JAR_NAME="console.jar"JAR_PATH=$CUR_SHELL_DIR/$JAR_NAME#JAVA_MEM_OPTS=" -server -Xms1024m -Xmx1024m -XX:PermSize=128m"JAVA_MEM_OPTS=""#SPRING_PROFILES_ACTIV="-Dspring.profiles.active=prod"SPRING_PROFILES_ACTIV=""JAR_LIB="-Dloader.path=libs/"echo_help(){ echo -e "syntax: sh $CUR_SHELL_NAME start|stop"}if [ -z $1 ];then echo_help exit 1fiif [ "$1" == "start" ];then# check server PIDS=`ps --no-heading -C java -f --width 1000 | grep $JAR_NAME | awk '{print $2}'` if [ -n "$PIDS" ]; then echo -e "ERROR: The $JAR_NAME already started and the PID is ${PIDS}." exit 1 fiecho "Starting the $JAR_NAME..." # start nohup java $JAR_LIB $JAVA_MEM_OPTS -jar $SPRING_PROFILES_ACTIV $JAR_PATH >> /dev/null 2>&1 & COUNT=0 while [ $COUNT -lt 1 ]; do sleep 1 COUNT=`ps --no-heading -C java -f --width 1000 | grep "$JAR_NAME" | awk '{print $2}' | wc -l` if [ $COUNT -gt 0 ]; then break fi done PIDS=`ps --no-heading -C java -f --width 1000 | grep "$JAR_NAME" | awk '{print $2}'` echo "${JAR_NAME} Started and the PID is ${PIDS}."elif [ "$1" == "stop" ];then PIDS=`ps --no-heading -C java -f --width 1000 | grep $JAR_NAME | awk '{print $2}'` if [ -z "$PIDS" ]; then echo "ERROR:The $JAR_NAME does not started!" exit 1 fiecho -e "Stopping the $JAR_NAME..." for PID in $PIDS; do kill $PID > /dev/null 2>&1 done COUNT=0 while [ $COUNT -lt 1 ]; do sleep 1 COUNT=1 for PID in $PIDS ; do PID_EXIST=`ps --no-heading -p $PID` if [ -n "$PID_EXIST" ]; then COUNT=0 break fi done done echo -e "${JAR_NAME} Stopped and the PID is ${PIDS}."else echo_help exit 1如果您喜欢本文,就请动动您的发财手为本文点赞评论转发,让我们一起学习更多运维相关知识,最后请记得关注我。

欢迎分享,转载请注明来源:

内存溢出

原文地址:

http://outofmemory.cn/tougao/670457.html
参数
(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
code code 管理员组
burberry香水官网价格_巴布瑞香水女士经典
上一篇
2022-04-19
杜蕾斯安全套真的安全吗_杜蕾斯破裂的概率
2022-04-19

发表评论
请登录后评论... 登录
提交

    评论列表(0条)
保存
{label} {label} `CUR_SHELL_DIR=`pwd`CUR_SHELL_NAME=`basename ${BASH_SOURCE}`#修改这里jar包名即可', author : 'code', cat_name : '投稿', time_y_m : '2022年04月', time_d : '19', site_motto : '内存溢出' }; {script} {script}