我正在使用curl命令来命中服务器。我正在回复标题正文。如果状态= 200服务器已启动。我是否编写shell脚本来检查我的服务器是否已关闭并触发邮件?
命令:
curl -X POST --header "Content-Type: application/json" --header "Accept: application/json" --header "X-Auth-Token: token which is generated after login " -d "{
\"authSource\": \"APKIRAI\",
\"email\": \"username\",
\"password\": \"password(xxx)\"}" "api url(login)"
响应:
{"status":1,"message":"All is well","body":{"token":"anandkhot.actovoice@gmail.com:1:1467298960095:405a3dcd524cd673ebc4fd59a31fbabc","expires":1467298960095}}
答案 0 :(得分:0)
这样的事情可能是一个起点......它会每隔10秒轮询你的网站,添加你的curl命令。
将它放在名为poll.sh的文件中,并使用sh poll.sh
while True
do
resp=$(curl )
if [ -z $resp ]
then
echo "Failed"
echo $resp
else
echo "OK"
fi
sleep 10
done