Skip to content

Instantly share code, notes, and snippets.

@dvryaboy
Created April 28, 2011 01:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dvryaboy/945595 to your computer and use it in GitHub Desktop.
Save dvryaboy/945595 to your computer and use it in GitHub Desktop.
Shell script to kill orphaned Hadoop Task processes
#!/bin/bash
# Kill tasks holding on to deleted userlogs. These are most likely abandoned jobs.
function get_bad_pids {
for i in `ps -ef | grep java | awk '{print $2;}'`; do
cnt=`/usr/sbin/lsof -p $i | grep deleted | grep /var/log/hadoop-0.20/userlogs/attempt | wc -l`;
if [ $cnt -gt 0 ]; then
PIDS=$i:$PIDS;
fi
done
}
PIDS=""
get_bad_pids
IFS=':'
for pid in $PIDS; do
kill -9 $pid;
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment