在Ubuntu 12.04服務器上,我有一個bash腳本來優雅地停止我的apache2服務器,刪除/var/www
的內容,解壓縮新內容並再次啓動apache。Bash腳本:等待apache2 graceful-stop
Test
Flush...
Flushed.
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs
Action 'start' failed.
The Apache error log may have more information.
所以腳本不會等待阿帕奇停止:當Apache重新開始(一切以root執行)
echo "Test";
cd /var;
service apache2 graceful-stop;
rm -R www/ && echo "Flush...";
unzip transfer.zip > /dev/null && echo "Flushed.";
service apache2 start;
我得到的錯誤是。
這裏是我試過到目前爲止:(同樣的錯誤)
我試圖等待與wait
service apache2 graceful-stop;
wait $!;
我試圖讓Apache的PID和等待這一個(同樣的錯誤)
pid=$(cat /var/run/apache2.pid)
apache2ctl graceful-stop;
wait $pid;
我試圖用apache2ctl graceful-stop
代替service apache2 graceful-stop
(同樣的錯誤)
我錯過了什麼?當我使用
service apache2 stop
,一切工作正常:
* Stopping web server apache2
... waiting [ OK ]
Flush...
Flushed.
* Starting web server apache2 [ OK ]
感謝
編輯
這裏與等待的退出代碼的輸出:
* Stopping web server apache2 [ OK ]
0
Flush...
Flushed.
* Starting web server apache2
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs
Action 'start' failed.
The Apache error log may have more information.
[fail]
是什麼等待的退出狀態? –
退出代碼爲'0' ... –
輸出不正確。更新我的問題。 –