php呼び出しshellプログラムゾンビプログラムdefunct
6916 ワード
phpでbash shellを呼び出す
clean_queue.shは以下の通りである.
ただし、このphpコードは実行時に終了しません.
最初は/usr/bin/http sqsの背景色が赤く、権限の問題だと思っていましたが、chmod u-s/usr/bin/http sqsがsuid属性を削除したのか、それとも問題が残っていますか.
その後httpsqsが起動してdeamonプログラムになったのではないかと感じ、呼び出されたphpはこのshellが結果がないと判断し、ずっと待っていて、nohupバックグラウンドを加えて実行してみました.以下のように書きます.
やはりゾンビプロセスは現れません.
system("/home/app/clean_queue.sh", $retval);
clean_queue.shは以下の通りである.
#!/bin/bash
sid="/data/httpsqs/queue"
pid=`ps -ef|grep -v grep|grep $sid|sed -n '1P'|awk '{print $2}'`
while [ -n "$pid" ]
do
echo "queue id=$pid"
kill $pid
pid=`ps -ef|grep -v grep|grep $sid|sed -n '1P'|awk '{print $2}'`
done
echo "has shutdown queue."
rm -rf /data/httpsqs/queue/httpsqs.db
echo "has delete queue db."
/usr/bin/httpsqs -d -p 1234 -x /data/httpsqs/queue
echo "has restarted page queue"
pid2=`ps -ef|grep -v grep|grep $sid|sed -n '1P'|awk '{print $2}'`
while [ -z "$pid2" ]
do
echo "queue has not been started, ready to retry."
/usr/bin/httpsqs -d -p 1234 -x /data/httpsqs/queue
pid2=`ps -ef|grep -v grep|grep $sid|sed -n '1P'|awk '{print $2}'`
done
echo "end check if started"
ただし、このphpコードは実行時に終了しません.
[root@script ~]# ps -ef|grep defunct
root 11273 21369 0 16:58 pts/0 00:00:00 php test_defunct.php
root 11275 11273 0 16:58 pts/0 00:00:00 [sh] <defunct>
root 11384 13877 0 16:59 pts/2 00:00:00 grep defunct
最初は/usr/bin/http sqsの背景色が赤く、権限の問題だと思っていましたが、chmod u-s/usr/bin/http sqsがsuid属性を削除したのか、それとも問題が残っていますか.
その後httpsqsが起動してdeamonプログラムになったのではないかと感じ、呼び出されたphpはこのshellが結果がないと判断し、ずっと待っていて、nohupバックグラウンドを加えて実行してみました.以下のように書きます.
system("nohup /home/app/clean_queue.sh > /home/app/log/clean_queue 2>&1", $retval);
やはりゾンビプロセスは現れません.