清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>
#! /bin/sh jobId=$2 jarpath=$3 isProcessFailTask=$4 echo "=========execute config.sh action: $1 jobId: $2 jarpath: $3 isProcessFailTask: $4" > "$jobId"log.log #start start(){ now=`date "+%Y-%m-%d %H:%M:%S"` echo "-----[date]:$now">> "$jobId"log.log if [ ! -f "$jarpath" ];then echo "-----$jarpath nonexistence please check....">> "$jobId"log.log exit fi echo "-----[start....] job:$jobId">> "$jobId"log.log nohup java -server -Xms1000m -Xmx1000m -Xmn512m -XX:+UseConcMarkSweepGC -XX:ParallelCMSThreads=2 -XX:+CMSClassUnloadingEnabled -XX:+UseCMSCompactAtFullCollection -XX:CMSInitiatingOccupancyFraction=80 -Xloggc:logs/.out -verbose:gc -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps -XX:+PrintGCDetails -XX:+PrintTenuringDistribution -XX:+PrintCommandLineFlags -XX:+DisableExplicitGC -Dlog.info.file="$jobId".log -jar $jarpath 100 10 4 10 50 $jobId $isProcessFailTask > startlog.log & sleep 3s pid=`ps ax | grep $jobId | grep java | head -1 | awk '{print $1}'` if [ -n "$pid" ];then echo "-----[started..successfully.] job:$jobId" >> "$jobId"log.log else echo "-----[start fail...] job:$jobId" >> "$jobId"log.log fi } #stop stop(){ now=`date "+%Y-%m-%d %H:%M:%S"` echo "-----[date]:$now">> "$jobId"log.log if [ ! -f "$jarpath" ];then echo "-----$jarpath nonexistence please check....">> "$jobId"log.log exit fi echo "-----[stopping...] job:$jobId...">> "$jobId"log.log pid=`ps ax | grep $jobId | grep java | head -1 | awk '{print $1}'` if [ -n "$pid" ];then kill -9 $pid echo "-----[stopped..successfully.] job:$jobId...pid:$pid" >> "$jobId"log.log else echo "-----[stop fail...] cause: no pid----" >> "$jobId"log.log fi } if [ ! "$4" ] ; then printf 'Usage: %s%s%s%s {start|stop|restart} {jobId} {jarpath} {isProcessFailTask}' >> "$jobId"log.log exit 1 fi case "$1" in start) start ;; stop) stop ;; restart) stop start ;; *) printf 'Usage: %s%s%s%s {start|stop|restart} {jobId}' >> "$jobId"log.log exit 1 ;; esac echo "-----end" >> "$jobId"log.log