課程
/運(yùn)維&測(cè)試
/Linux
/shell編程之條件判斷與流程控制
我的腳本含有改名httpd_text.sh后,再運(yùn)行它。還是顯示httpd down,然后啟動(dòng)httpd 老師這是怎么了?
2016-01-21
源自:shell編程之條件判斷與流程控制 3-3
正在回答
#!/bin/bash
應(yīng)該是第一句的問(wèn)題,要寫(xiě)在第一行開(kāi)頭,不要省不要錯(cuò)
你的centos是7的? 如果是的話? /etc/rc.d/init.d/httpd start就啟動(dòng)不了 httppd服務(wù),centos7? 用systemctl命令代替了service ,然后? /etc/rc.d/init.d/httpd 也沒(méi)有了。如果是的話你可以百度下systemctl的用法
? 3 #!/bin/bash
? 4?
? 5 test=$( ps aux | grep httpd |grep -v grep )
? 6?
? 7 if [ -n ?"$test" ?]
? 8 ? ?then
? 9 ? ? ? printf "%s %s\n" ?httpd up
?10 ? ?else
?11 ? ? ?/etc/rc.d/init.d/httpd start
?12 ? ? ?printf "%s %s\n" ?httpd down
?13 fi
~ ? ? ??
腳本貼上了看看唄
linhaa 提問(wèn)者
舉報(bào)
Linux shell實(shí)用案例學(xué)習(xí),一定會(huì)使你Linux運(yùn)維能力再次提高
2 回答shell腳本執(zhí)行后沒(méi)輸出
2 回答Shell腳本運(yùn)行報(bào)錯(cuò):[: : integer expression expected
1 回答腳本apache啟動(dòng)命令無(wú)法執(zhí)行
2 回答$在腳本中都在什么情況下使用
2 回答請(qǐng)問(wèn)虛擬機(jī)linux編寫(xiě)的腳本文件怎樣導(dǎo)出來(lái)?
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號(hào)-11 京公網(wǎng)安備11010802030151號(hào)
購(gòu)課補(bǔ)貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動(dòng)學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號(hào)
2017-07-13
#!/bin/bash
應(yīng)該是第一句的問(wèn)題,要寫(xiě)在第一行開(kāi)頭,不要省不要錯(cuò)
2016-10-24
你的centos是7的? 如果是的話? /etc/rc.d/init.d/httpd start就啟動(dòng)不了 httppd服務(wù),centos7? 用systemctl命令代替了service ,然后? /etc/rc.d/init.d/httpd 也沒(méi)有了。如果是的話你可以百度下systemctl的用法
2016-01-26
? 3 #!/bin/bash
? 4?
? 5 test=$( ps aux | grep httpd |grep -v grep )
? 6?
? 7 if [ -n ?"$test" ?]
? 8 ? ?then
? 9 ? ? ? printf "%s %s\n" ?httpd up
?10 ? ?else
?11 ? ? ?/etc/rc.d/init.d/httpd start
?12 ? ? ?printf "%s %s\n" ?httpd down
?13 fi
~ ? ? ??
2016-01-23
腳本貼上了看看唄