Skip to content

Instantly share code, notes, and snippets.

@jtoy
Forked from dvryaboy/kill_hadoop_orphans.sh
Created April 28, 2012 16:57
Show Gist options
  • Save jtoy/2520214 to your computer and use it in GitHub Desktop.
Save jtoy/2520214 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