Finlay
1
Hi folks
This is my first post, nice to meet y’all.
I’d really like some constructive criticism (hope I’m posting in the right place).
#! /bin/bash
for var in "$@"
do
line=$(ps -fC $var | grep root)
if [ -z "$line" ]
then
killall -9 $var
fi
done
exit 0
Is the logic ok? Any potential problems?
it’s rubbish if it’s supposed to show all logged on users…
Sorry, my roundabout way of saying “it might help if you stated what the script is supposed to do” 
Finlay
3
thanks.
Iterate over parameters, check if process is owned by root, if not kill it.
Wouldn’t:
pgrep -v -u root
identify all non root owned processes by PID ?
as the “-v” option makes it the “inverse” of:
pgrep -u root
then just pipe the returned PID list to “killall -9” … just a thought.
or maybe I’m over-thinking it :-\
Mmm, I think all you need is;
#! /bin/bash
for var in "$@"
do
pkill -v -u root ${var}
done
But I’ll let you test it on your system … . :o
Finlay
6
You guys are very funny!
That kills all processes except the one specified as the argument!
