Summary: Killing process with a shell script

From: Andreas Hoeschler <ahoesch_at_smartsoft.de>
Date: Tue Jan 13 2004 - 11:39:39 EST
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@sunmanagers.org
> http://www.sunmanagers.org/mailman/listinfo/sunmanagers
_______________________________________________
sunmanagers mailing list
sunmanagers@sunmanagers.org
http://www.sunmanagers.org/mailman/listinfo/sunmanagers
Received on Tue Jan 13 11:39:35 2004

This archive was generated by hypermail 2.1.8 : Thu Mar 03 2016 - 06:43:25 EST