Wow! When was the last time you needed to kill a bunch of rampant processes on a unix server?
I needed to do that today this is how I did it:
processes=`ps -ef | grep -i glassfish | awk '{print $2}'`
for a in $processes
do
if [ $a -gt 5000 ]
then
if [ $a -lt 10000 ]
then
sudo kill -9 $a
fi
fi
done
How would you do it? Notice the nested if statements - this is a much more verbose but yet clearer way to code the if (x > 5000 && x < 10000) which isn't too bad but if you need another &&or an || or two it gets nasty quick.
-Aaron
No comments:
Post a Comment