我有这样的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”。但在其他情况下没有问题。我的语法错误或任何逻辑错误。
谢谢...
答案 0 :(得分:1)
你应该试试这个......
(java -jar clientApplication.jar $s &)
......而不是......
java -jar clientApplication.jar $s &
如果确实有效,请看看nohup