我需要shell脚本来在关闭时重新启动HTTPD。我在网上搜索时发现了一些脚本,但无法正常显示语法错误。
#!/bin/bash
RESTART="/sbin/service httpd restart"
PGREP="/usr/bin/pgrep"
HTTPD="httpd"
$PGREP ${HTTPD}
if [ $? -ne 0 ] # if apache not running
then
# restart apache
$RESTART
fi
当我运行此脚本时,显示错误
[root@vmi194867 pydash]# bash -x /scripts/httpd.sh
: No such file or directory/usr/bin/pgrep // path is correct
/scripts/httpd.sh: line 10: syntax error near unexpected token `fi'
/scripts/httpd.sh: line 10: `fi'