更新时间:2023-12-05 11:15:22
尝试以下操作:
if ssh -qn root@ip pidof httpd &>/dev/null ; then
echo "Apache is running";
exit 0;
else
echo "Apache is not running";
exit 1;
fi
这些exit
命令也会发送正确的 EXIT_SUCCESS 和 EXIT_FAILURE (如果需要,将来可用于扩展此脚本).
These exit
commands will send the correct EXIT_SUCCESS and EXIT_FAILURE too ( Will be usefull to extend this script in future, if you need ).
但是有一个建议:***将脚本作为远程进程使用ssh帐户与sudoer用户一起运行