Re: Scripting Question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Saturday 11 January 2003 12:28, Thom Paine uttered:
> That seems to have fixed that.
>
> How hard would it be to record the process and then kill it in a cron job?

Extremely easy.  The process variable does exactly that, it records the 
process ID.  If you wanted to kill it, all you would have to do is something 
like this:

process=`ps auxwww | grep q3ded | grep -v grep | awk '{ print $2 }'`
if [ ! -z $process ]; then
echo "Quake3 process found, killing it w/ extreme prejudice"
kill -9 $process
echo ""
fi

Of course, this doesn't work as expected if you have multiple instances of 
quake3 running.  What you would really want to do is drop it into a for loop:

for process in `ps auxwww | grep q3ded | grep -v grep | awk '{ print $2 }'`
do echo "Quake3 process found, killing it w/ extreme prejudice";
kill -9 $process;
done

This will loop through every process returned that matches q3ded, and kills it 
with -9.  If no process is found, nothing is killed.

Of course, this is all overkill, since "killall" and "pkill" expect a process 
name.  killall -9 q3ded  would accomplish the exact same thing.

-- 
Jesse Keating RHCE MCSE
For Web Services and Linux Consulting, Visit --> j2Solutions.net
Mondo DevTeam (www.mondorescue.org)

Was I helpful?  Let others know:
 http://svcs.affero.net/rm.php?r=jkeating



-- 
Psyche-list mailing list
Psyche-list@redhat.com
https://listman.redhat.com/mailman/listinfo/psyche-list

[Index of Archives]     [Fedora General Discussion]     [Red Hat General Discussion]     [Centos]     [Kernel]     [Red Hat Install]     [Red Hat Watch]     [Red Hat Development]     [Red Hat 9]     [Gimp]     [Yosemite News]

  Powered by Linux