1
尝试编写可继续远程测试服务器的shell脚本,但注销时该脚本始终落在else语句中
尝试在此处编写一个shell脚本,该脚本不断测试我的服务器,并在出现故障时向我发送电子邮件。 问题是,当我从ssh连接注销时,尽管&在命令末尾(如)运行ssh连接,它./stest01.sh &仍自动落入else并保持不间断地向我发送邮件,直到我再次登录并杀死它。 #!/bin/bash while true; do date > sdown.txt ; cp /dev/null pingop.txt ; ping -i 1 -c 1 -W 1 myserver.net > pingop.txt & sleep 1 ; if grep "64 bytes" pingop.txt ; then : else mutt -s "Server Down!" myemail@address.com < sdown.txt ; sleep 10 ; fi …