Re: Scripting Question

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

 



 
 
-------Original Message-------
 
From: psyche-list@redhat.com
Date: Saturday, January 11, 2003 3:43:38 PM
To: psyche-list@redhat.com
Subject: Re: Scripting Question
 
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.
 

Oh, cool. killall -9 q3ded would be what I want, as I would only ever have
one copy of q3ded running. I'd like to rotate different game servers on
different nights automatically. I'd rather not have more that one game
server running, to keep the performance up.

Thanks for your help.



-- 
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