# $Name: teleport_check.sh
# $Version: v1.0
# $Function: check teleport status
# $Author: fhb
# $Create Date: 2020-07-14
# $Description: shell
######################################################
#注意此脚本未加文件锁
Teleport_command=/etc/init.d/teleport
#日志文件路径
Teleport_log=/var/log/teleport/teleport_check.log
#获取服务当前状态
Teleport_status=`${Teleport_command} status |awk '{print $5$6}' |grep 'notrunning.'`
#根据服务状态进行判断操作
if [ "$?" -eq 0 ]
then
echo "$(date +%F_%T)" >> ${Teleport_log}
echo "$(${Teleport_command} status)" >>${Teleport_log}
$Teleport_command restart
echo "$(${Teleport_command} status)" >>${Teleport_log}
else
echo ""
fi