自动化

jira、confluence服务挂了,用下面的脚本试试

2020-02-10  本文已影响0人  佛系小懒

脚本是定时去check端口是否还在占用,如果没有执行重启操作;

#!/bin/sh

echo " "

echo ">>>>>>>>>>>>shell is doing【make by rcl】>>>>>>>>>>>>"

echo " "

echo " "

CF_PORT=XXXX

JIRA_PORT=XXXXX

ES_PORT=XXXXXX

DATANODE_PORT=XXXXXXXX

if [! -f"/opt/wiki_out.log" ]

then

        touch "/opt/wiki_out.log";

fi

while true;do

    process=`netstat -nlp |grep ${CF_PORT} |grep -v grep`;

echo "check confluence"

    if ["$process" !="" ]

then

            echo "【Print】confluence was started";

echo "【INFO】`date '+%Y-%m-%d %H:%M:%S'`  check.shell confluence is running…… \n">>/opt/wiki_out.log;

else

            echo "【Print】please wait,confluence is starting……";

echo " ";

rm -f /opt/atlassian/confluence/work/catalina.pid# 删除pid文件

            service confluence6 start

fi

    echo " ";

process=`netstat -nlp |grep ${JIRA_PORT} |grep -v grep`;

echo "check jira"

    if ["$process" !="" ]

then

            echo "【Print】jira was started";

echo "【INFO】`date '+%Y-%m-%d %H:%M:%S'`  check.shell jira is running…… \n">>/opt/wiki_out.log;

else

            echo "【Print】please wait,jira is starting……";

echo " ";

service jira1 start

fi

    echo " ";

process=`netstat -nlp |grep ${ES_PORT} |grep -v grep`;

echo "check es"

    if ["$process" !="" ]

then

            echo "【Print】es was started";

echo "【INFO】`date '+%Y-%m-%d %H:%M:%S'`  check.shell es is running…… \n">>/opt/wiki_out.log;

else

            echo "【Print】please wait,es is starting……";

echo " ";

service es start

fi

    echo " ";

process=`netstat -nlp |grep ${DATANODE_PORT} |grep -v grep`;

echo "check datanode"

    if ["$process" !="" ]

then

            echo "【Print】datanode was started";

echo "【INFO】`date '+%Y-%m-%d %H:%M:%S'`  check.shell datanode is running…… \n">>/opt/wiki_out.log;

else

            echo "【Print】please wait,datanode is starting……";

echo " ";

start-dfs.sh

    fi

    echo " ";

sleep 3600s

echo ""> /opt/wiki_out.log

done

echo " "

echo ">>>>>>>>>>>>shell was done【make by rcl】>>>>>>>>>>>>"

echo " "

上一篇下一篇

猜你喜欢

热点阅读