I have a job dispatcher bash shell script containing below codes:
for (( i=0; i<$toBeDoneNum; i=i+1 ))
do
while true
do
processNum=`ps aux | grep Checking | wc -l`
if [ $processNum -lt $maxProcessNum ]; then
break
fi
echo "Too many processes: Max process is $maxProcessNum."
sleep $sleepSec
done
java -classpath ".:./conf:./lib/*" odx.comm.cwv.main.Checking $i
done
I run the script like this to be in the background:
./dispatcher.sh &
I want to terminate this dispatcher process with kill -9
. But I didn't record the pid of the dispatcher process at the first time. I used jobs, jobs -l
, jobs -r
and jobs -s
. Nothing showed. Even this fg
cannot bring the process to foreground.
fg
bash: fg: current: no such job
But I think this dispatcher process is still running because it still continues to assign java program to run (already used top and ps -ef
to check). How should I terminate this job dispatcher bash shell script process?
while
andfor
processes. – slm Jan 13 '14 at 04:15ps l
lines for some of these Java processes, look at the PPID line and see what their parent is. – Gilles 'SO- stop being evil' Jan 13 '14 at 21:55-9
is equivalent to-KILL
and should be preferred as it is self-explanatory. Further, I think you should not recommendSIGKILL
as the first aid. Rather than that I would post in this order:pkill -HUP
,pkill -TERM
,pkill -KILL
in a non-specific answer. – Vlastimil Burián Apr 14 '17 at 06:32