Created
July 12, 2013 19:03
-
-
Save msilvey/5986887 to your computer and use it in GitHub Desktop.
A loop to remove old staging dirs. This is a part of the workaround for a bug tracked here: https://issues.apache.org/jira/browse/MAPREDUCE-5351
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| NOW=`date +%s` | |
| SIXHOURSAGO=`echo "$NOW - 21600" |bc` | |
| HADOOPBIN="/usr/bin/hadoop" | |
| IFS=$'\n' | |
| for i in `$HADOOPBIN fs -ls /user/root/.staging/`; do | |
| IFS=' ' | |
| JOBDATE=`echo $i|awk '{print $6" "$7}'` | |
| JOBTS=`date --date="$JOBDATE" +"%s"` | |
| if [ $SIXHOURSAGO -gt $JOBTS ]; then | |
| FILE=`echo $i|awk '{print $8}'` | |
| $HADOOPBIN fs -rm -r $FILE | |
| fi | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, I need your help with the above script.
I used your script to help me with same issue i have right now, but my lead wants it to be hard coded so that anytime in future it wont end up deleting the filesystem.
Can you please help