Skip to content

Instantly share code, notes, and snippets.

@vikrum vikrum/sak.sh
Created Feb 4, 2013

Embed
What would you like to do?
Oh, don't mind me, I'm just running roughshod over your processes.
#!/bin/bash
#
# seek and kill a mem hog fork()'d child
#
SEEK="stud"
SNOOZE="6000"
while [ : ]; do
echo Snoozing for $SNOOZE
sleep $SNOOZE
LINE=`ps auxwf|grep $SEEK|grep -v grep|tail -n+2|sort -nk6|tail -1`
if [ -z "$LINE" ];
then
echo No proc
else
PROC=`echo $LINE | awk '{print $2}'`
MEM=`echo $LINE | awk '{print $6}'`
echo The $SEEK pid $PROC is using $MEM ... killing it.
kill $PROC
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.