還得我想了10分鐘才明白”!=“和"-n"的用法區(qū)別,做個(gè)筆記捋一捋
第一種方法:測(cè)試apache是否開啟?字符串測(cè)試
#!/bin/bash
web=`/usr/bin/pgrep httpd`
if [ -n "$web" ]; //$web返回值是否為空
then
echo "httpd is running"
else
/etc/init.d/httpd start
fi
第二種:
#!/bin/bash
web=`/usr/bin/pgrep httpd`
if [ "$web" !=“” ]; //$web返回值是否等于空
then
echo "httpd is running"
else
/etc/init.d/httpd start
fi
新聞熱點(diǎn)
疑難解答
圖片精選