Linux 通过keeo-watching命令在ssh故障时发送电子邮件

Linux 通过keeo-watching命令在ssh故障时发送电子邮件,linux,email,ssh,sh,Linux,Email,Ssh,Sh,当ssh问题得到解决时,应该触发电子邮件,所以使用带有电子邮件触发器的watch,但不起作用,并保持挂起状态。为什么它会在挂州 watch-n600如果[!`sshuser@linux.example.com` ]; 然后mailx-s“ssh现在正常了” bash-4.1$watch-n600如果[!sshuser@linux.example.com];然后mailx-s“ssh现在正常了”example@example.com; fi FIPS完整性验证测试失败。 ssh:连接到主机linu

当ssh问题得到解决时,应该触发电子邮件,所以使用带有电子邮件触发器的watch,但不起作用,并保持挂起状态。为什么它会在挂州

watch-n600如果[!`sshuser@linux.example.com` ]; 然后mailx-s“ssh现在正常了”

bash-4.1$watch-n600如果[!
sshuser@linux.example.com
];然后mailx-s“ssh现在正常了”example@example.com; fi

FIPS完整性验证测试失败。 ssh:连接到主机linux.example.com端口22:连接被拒绝 ^C (中断——还有一个终止字母)

为什么不使用:

#/bin/bash
虽然真实;做
如果nc-w 10user@server.com22>/dev/null 2>&1;然后
echo“ssh可访问”| mail-s“ssh现在正常”some@email.com
打破
fi
睡600
完成
假设
sleep
等待时间为600秒,连接
超时时间为10秒,端口为:
22