shell总结

来源:互联网 发布:黑苹果安装软件 编辑:程序博客网 时间:2024/05/07 01:28

启动jar包脚本

#!/bin/shnohup java -jar  ./overseasNews.jar > /dev/null 2>&1 &echo `jps | grep overseasNews.jar | grep -v grep ` " started!!!"

停止指定线程脚本

#!/bin/shinfo=`ps -ef|grep  overseasNews.jar  |grep -v grep`echo "killing thread info ####### " $infopid=`echo $info |awk '{print $2}' `kill -9 $pidecho "pid " $pid " ##### killed!!!!"

两个脚本合并,通过输入参数控制启动和停止

#!/bin/sh if [ $# = 1 ] && [ $1 = "start" ] ; then   nohup java -jar  ./overseasNews.jar > /dev/null 2>&1 &   echo `jps | grep overseasNews.jar | grep -v grep ` " started!!!" elif [ $# = 1 ] && [ $1 = "stop" ] ; then   info=`ps -ef|grep  overseasNews.jar  |grep -v grep`   echo "killing thread info ####### " $info   pid=`echo $info |awk '{print $2}' `   kill -9 $pid   echo "pid " $pid " ##### killed!!!!" else  echo " arg error the only argument is start/stop"  fi


原创粉丝点击