logo       

Summary: Killing process with a shell script: msg#00004

os.solaris.managers.summaries

Subject: Summary: Killing process with a shell script

Dear Manager,

thanks to all (too many to list) that responded to my question. The following script seems to solve my problem:

#!/bin/sh
pid=`/usr/bin/ps -ef | /usr/bin/grep pop-before-smtp | grep -v grep| awk -F' ' '{print $2}'`;
if test "$pid" = "" ; then
echo "Process does not run yet!";
else
echo "Killing process..."
kill $pid;
fi
echo "Restarting pop-before-smtp...";
nohup /usr/local/bin/pop-before-smtp &

Thanks a lot!

Regards,

Andrea

I am desparately trying to figure out how to kill a process (the complete path is given) with a shell script.

#!/bin/sh
a=`/usr/bin/ps -ef | /usr/bin/grep pop-before-smtp | grep -v grep`;
if test "$a" = "" ; then
echo "Does not run!";
else
echo "Trying to kill, but how?"
fi

I can determine whether the process runs. The above gives me

root 27721 1 0 Dec 06 ? 0:00 /usr/local/bin/pop-before-smtp

in the variable a. But how can I isolate the pid of the process so that I have something to pass to kill?

Thanks a lot!

Regards,

Andreas
_______________________________________________
sunmanagers mailing list
sunmanagers@xxxxxxxxxxxxxxx
http://www.sunmanagers.org/mailman/listinfo/sunmanagers


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise