#!/bin/sh
function checkApache()
{
netstat -ant | grep :80
if [ $? -eq 1 ];then
echo date +%Y-%m-%d--%X
port :80 error Apache does not works! >> svrmon.log
sudo /etc/init.d/apache2 start > /dev/null 2>&1
fi
return 0
}
while true:
do
checkApache
done
运行结果:
apache.sh: line 14: 在未预料的“done”附近出现语法错误
apache.sh: line 14: `done'
是不是脚本对齐格式等。tab键对齐了没