shellスクリプトはjarの起動と停止を制御します



  
#! /bin/sh

#    
start(){

        java -Xms128m -Xmx2048m -jar test1.jar 5 > result.log &
        java -Xms128m -Xmx2048m -jar test2.jar 5 > result.log &
        tail -f result.log
}
#    
stop(){
        ps -ef|grep test|awk '{print $2}'|while read pid
        do
           kill -9 $pid
        done
}

case "$1" in
start)
  start
  ;;
stop)
  stop
  ;;
restart)
  stop
  start
  ;;
*)
  printf 'Usage: %s {start|stop|restart}
' "$prog" exit 1 ;; esac