checking if service is running and if so kill it
Hi everyone,
I am wanting to do the following:
check if a process is running, if it is then we kill it.
I have been able to get the PID of the process which is now known as
$PID
but i need to now using:
ps -ef | grep $PID | grep -v grep
I can list the item but then how do I go about checking etc.
something like
$CHECK=`$ps -ef | $grep $PID | $grep -v grep`
if [ $CHECK == "" ]
echo "Service has shutdown correctly"
fi
echo "Service did not shut down correctly"
echo "Killing service"
kill -9 $PID
it is the if [ blah blah ] that I am unclear on.
Thanks
|