重启 restart.sh

重启 restart.sh 

#!/bin/bash
LOG=nohup.out
PID=$(netstat -tpln|grep 5044 | cut -d 'N' -f2 | sed -s "s/\/java//g")
#PID=$(jps | grep $MODULE | cut -f 1 -d ' ')
#PID=$(lsof -i :$PORT | head -n 2 | grep java | awk '{printf $2}')
#PID=`ps -ef | grep filebeat | grep -v color | awk '{printf $2}'`

if [ -n $PID ]
then
    echo $1 >> $LOG
    echo 'PID: '$PID >> $LOG
    echo 'kill -9 '$PID >> $LOG
    kill -9 $PID
fi

sh start.sh

  

 pid.sh

#!/bin/bash
LOG=nohup.out
PID=$(pidof 'filebeat')
echo 'pidof: '$PID >> nohup.out
if [[ $PID =~ ^[0-9]+$ ]]
then
	tail -n 10  nohup.out 
fi

 

stop.sh

echo "================= stop `date +%Y%m%d' '%H:%M:%S` ==============="
PID=$(pidof 'filebeat')
echo 'kill pidof: '$PID 
if [[ $PID =~ ^[0-9]+$ ]]
then
	echo 'kill -9 '$PID
	kill -9 $PID
fi

  

pid.sh

#!/bin/bash
PID=$(pidof 'filebeat')
echo "=================pid `date +%Y%m%d' '%H:%M:%S` ==============="
echo 'pid: '$PID 

 

start.sh

#!/bin/bash
echo "================= start `date +%Y%m%d' '%H:%M:%S` ==============="
nohup ./filebeat -e >> nohup.out 2>&1 &
echo 'THIS PID: '$! 
#tail -fn 30 nohup.out

  

 

restart.sh

#!/bin/bash
bash stop.sh
bash start.sh

  

 

posted @ 2024-05-17 19:27  xiluhua  阅读(22)  评论(0编辑  收藏  举报