监控指定任务,结束钉钉通知

#!/bin/bash set -e ## 上图中 access_token字段 TOKEN='' KEYWORD='hello' # 前文中设置的关键字 function call_webhook() { local msg=$1 local body=$(cat <<EOF { "at":{ "atMobiles":["1888888888"] }, "text":{ "content":"{{KEYWORD}} {{MSG}}" }, "msgtype":"text" } EOF ) echo $body | sed -e "s#{{MSG}}#$msg#g" -e "s#{{KEYWORD}}#$KEYWORD#g" | curl --location --request POST "https://oapi.dingtalk.com/robot/send?access_token=$TOKEN" \ --header 'Content-Type: application/json' \ --data @- } target_pid=52397 while true do if ps -p $target_pid > /dev/null then echo "PID $target_pid is running $(date)" else echo "PID $target_pid is not running. Sending notification..." call_webhook "PID $target_pid job run over" exit ; fi sleep 60 done
上一篇:Redis缓存更新策略


下一篇:UE5+GIS技术应用场景介绍