--- In [email protected], John Crispin <[EMAIL PROTECTED]> wrote:
>
> lo geert,
>
> what is pgrep ???
>
> john
>
>
Hi John,
pgrep/pkill is a kind of "special" grep function/kill function that
returns immediately the PID of the process you're looking for/want to
kill.
You don't have to do any more stuff like this:
#!/bin/sh
PROCESSLINE="`ps | grep ./main | grep -v grep`"
# Check if the string PROCESSLINE is empty, by using the -n test operator
if [ -n "$PROCESSLINE" ];
then
echo ==> Process exists, so kill it, dude!
PROCESSID="`expr substr \"$PROCESSLINE\" 1 5`"
kill -9 $PROCESSID
echo Give 3 seconds time to completely stop the running application
sleep 3
else
echo No such process currently running...
fi
to find the PID of an application and eventually kill it like I wrote
in the above script...
Just saw it today used by one of my colleagues in our current project
and I could perfectly use this command for my own needs...
Best rgds,
--Geert