[英]send an email on ssh failiure by keeo watching command
an email should trigger when ssh issue is resolved , so using watch with email trigger but is not working, and keep going in hang state.解决 ssh 问题时应触发电子邮件,因此将 watch 与电子邮件触发器一起使用但不起作用,并继续处于挂起状态。 Why it is going in hang state
为什么它进入挂起状态
watch -n 600 if [ ! `ssh user@linux.example.com` ]; then mailx -s "ssh is ok now"
bash-4.1$ watch -n 600 if [ ! bash-4.1$ watch -n 600 如果 [ !
ssh user@linux.example.com
]; ssh user@linux.example.com
]; then mailx -s "ssh is ok now" example@example.com;然后 mailx -s "ssh 现在可以了" example@example.com; fi
菲
FIPS integrity verification test failed. FIPS 完整性验证测试失败。 ssh: connect to host linux.example.com port 22: Connection refused ^C (Interrupt -- one more to kill letter)
ssh:连接到主机 linux.example.com 端口 22:连接被拒绝 ^C(中断 - 再多一个杀死信)
Why not use:为什么不使用:
#/bin/bash
while true;do
if nc -w 10 user@server.com 22 >/dev/null 2>&1;then
echo "ssh is accessible"| mail -s "ssh is ok now" some@email.com
break
fi
sleep 600
done
Assuming sleep
wait is 600 seconds, and the connect timeout
is 10 seconds, and port is: 22
假设
sleep
等待时间为 600 秒,连接timeout
为 10 秒,端口为: 22
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.