Skip to content

Instantly share code, notes, and snippets.

View prateekkakirwar's full-sized avatar

Prateek Kakirwar prateekkakirwar

View GitHub Profile
@prateekkakirwar
prateekkakirwar / clean_hdfs_tmp.rb
Created August 3, 2016 23:59 — forked from thattommyhall/clean_hdfs_tmp.rb
Clean up files/folders older than 5 days on HDFS
#!/usr/bin/env ruby
require "date"
five_days_ago = Date.parse(Time.now.to_s) - 5
IO.popen("hadoop fs -lsr /tmp").each_line do |line|
permissions,replication,user,group,size,mod_date,mod_time,path = *line.split(/\s+/)
if (mod_date)
if Date.parse(mod_date.to_s) < five_days_ago
puts line
if permissions.split('')[0] == 'd'