我有這樣的shell腳本。如果shell腳本中的條件
#!/bin/sh
s=$1
pro=`ps -ef | grep $s | grep -v grep | grep -v test3.sh | wc -l`
if [ $pro -eq 0 ]
then
echo "Service $s is DOWN..."
echo "Service $s is DOWN..." >> processlogs.txt
echo "Starting Service $s..."
echo "Starting Service $s..." >> processlogs.txt
java -jar clientApplication.jar $s &
else
echo "Service $s is Running..."
echo "Service $s is Running..." >> processlogs.txt
fi
當我執行shell腳本,並且操作進入if條件時,它永遠不會回來。它不斷執行命令「java -jar clientApplication.jar $ s」。但在其他情況下沒有問題。是我的語法錯誤還是任何邏輯錯誤。
謝謝...
$ pro將始終至少爲1,因爲您將's'設置爲$ 1並且$ 1應該顯示在ps -ef | grep $ s – 2013-02-13 05:39:40