This file contains 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
ls -1 /var/run/cloudera-scm-agent/process/ | while read line; do id=$(echo $line | cut -d "-" -f1); process=$(echo $line | sed -e "s/^[0-9]*-//"); echo "$process $id"; done | sort -k1,1r -k2,2nr | while read key value; do if [ "$cur_key" = "$key" ]; then echo -n ",$value"; else if [ "" != "$cur_key" ]; then echo; fi; echo -n "$key:$value"; cur_key=$key; fi; done | grep "." | while read line; do process=$(echo $line | cut -d ":" -f1); ids=$(echo $line | cut -d ":" -f2 | sed -e "s/,/ /g"); first=0; for i in $ids; do if [ "0" = "$first" ]; then first=1; else echo "Deleting /var/run/cloudera-scm-agent/process/${i}-${process}"; rm -fr "/var/run/cloudera-scm-agent/process/${i}-${process}"; fi; done; done |