Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@vikrum
Created February 4, 2013 22:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vikrum/4710398 to your computer and use it in GitHub Desktop.
Save vikrum/4710398 to your computer and use it in GitHub Desktop.
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