Memory consumption on a per user basis
Boruch Baum
boruch_baum at gmx.com
Sun Nov 11 17:16:07 IST 2018
On 2018-11-11 16:36, Josh Roden wrote:
> Hi everyone
> I have a CentOS 6 machine used by around 20 to 30 students
> at a time and I need to do one of two things:
> 1. find and kill top memory user with script
You can use 'smem'[1] to ferret out the process hogging the most memory
by as computed by 'proportional set size'[2]. A basic command to
retrieve the worst offending PID would be:
smem -c pid | tail -n1
How about this for a simple script?:
NAUGHTY="$(smem -c pid | tail -n1)"
for SIG in 15 15 15 9 9
do
kill -$SIG $NAUGHTY
printf "Sending signal $SIG to process $NAUGHTY\n"
sleep 1
ps -$naughty || exit
printf "Process $NAUGHTY is Still alive\n"
done
[1] https://www.selenic.com/smem/
[2] https://en.wikipedia.org/wiki/Proportional_set_size
--
hkp://keys.gnupg.net
CA45 09B5 5351 7C11 A9D1 7286 0036 9E45 1595 8BC0
More information about the Linux-il
mailing list