I want to delete the partition folders which are older than N days.
The below command gives the folders which are exactly 50 days ago. I want the list of all folders wh
It can be done with a bash
script
today=`date +'%s'`
hdfs dfs -ls /data/publish/DMPD/VMCP/staging/tvmcpr_usr_prof/ | grep "^d" | while read line ; do
dir_date=$(echo ${line} | awk '{print $6}')
difference=$(( ( ${today} - $(date -d ${dir_date} +%s) ) / ( 24*60*60 ) ))
filePath=$(echo ${line} | awk '{print $8}')
if [ ${difference} -lt 50 ]; then
echo "${filepath}"
fi
done
You can try with solr hdfsfindtool:
hadoop jar /opt/cloudera/parcels/CDH/lib/solr/contrib/mr/search-mr-job.jar org.apache.solr.hadoop.HdfsFindTool -find /data/publish/DMPD/VMCP/staging/tvmcpr_usr_prof -mtime +50 | xargs hdfs dfs -rm -r -skipTrash