Hadoop directories delete older than a month


 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Hadoop directories delete older than a month
# 1  
Old 05-05-2018
Hadoop directories delete older than a month

Code:
-bash-4.1$ hdfs dfs -ls -R /data/backup/prd/xyz/ | grep '^d'

drwxr-xr-x - abisox abadmgrp 0 2018-05-05 01:03 /data/backup/prd/xyz/20180301

drwxr-xr-x - abisox abadmgrp 0 2018-05-05 01:03 /data/backup/prd/xyz/20180302

drwxr-xr-x - abisox abadmgrp 0 2018-05-05 01:03 /data/backup/prd/xyz/20180413

drwxr-xr-x - abisox abadmgrp 0 2018-05-05 01:03 /data/backup/prd/xyz/20180423

drwxr-xr-x - abisox abadmgrp 0 2018-05-05 01:03 /data/backup/prd/xyz/20180501

drwxr-xr-x - abisox abadmgrp 0 2018-05-05 01:03 /data/backup/prd/xyz/20180502

drwxr-xr-x - abisox abadmgrp 0 2018-05-05 01:03 /data/backup/prd/xyz/20180505

I Want to delete these date directories like "20180301" from hadoop older than one month

Please suggest on this.
Moderator's Comments:
Mod Comment Please use code tags next time, thanks

Last edited by vbe; 05-05-2018 at 10:24 AM.. Reason: code tags
# 2  
Old 05-05-2018
Use find and mtime !

Hello,
discussed a lot of times.

Use find and mtime ..... and exec rm

Have a look at :
Find files older than 30 days in directories and delete them

Regards
# 3  
Old 05-06-2018
bdittmar gave you the "standard" way to proceed in such case, only if what I see is what I think in your copy/paste of command result, I understand you cannot use the timestamp, is that so?
In which case its more based on the directory name itself, which seems to me quite easy:
Ever thought of using it it as an integer,?
Use the highest value and substract 70 ( a quick guess...) giving the reference value: anything smaller be a candidate for removal...


My 2 cents
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to compress the directories which is older than 7 days?

Hi all, how to compress the directories which is older 7 days. If any one knows please help me this is urgent. Thanks in advance (3 Replies)
Discussion started by: rameshpagadala
3 Replies

2. Shell Programming and Scripting

Getting month older

I need month older lines from a file file 1 666 2013-08-23 04:24:11 33 543 2013-06-11 18:04:20 33 413 2013-06-20 1:40:54 1 776 2013-08-20 18:04:21 .0 877 2013-08-21 05:50:04 I'm checking older lines... (8 Replies)
Discussion started by: Roozo
8 Replies

3. Shell Programming and Scripting

find file older than one month not by x days olds

Hi, I would like to ask about some question on the -mtime option in the find command. I want to move a log files older than one month and planning to used the find -mtime +30 but i have some clarrification does -mtime +30 or -30 refer to x days beyond or between so how about the month. suppose... (2 Replies)
Discussion started by: jao_madn
2 Replies

4. Shell Programming and Scripting

Finding directories older than 5 days

Hello, Motive: Search all directories which are older than 5 days. Example: consider following directory structure: abc/dir1 abc/dir1/dir abc/dir2 abc/dir3 abc/dir3/temp Suppose dir1 and dir3 are 5 days older. Then I am looking for a command which lists abc/dir1 and abic/dir3 only so that... (4 Replies)
Discussion started by: mytempid07
4 Replies

5. Shell Programming and Scripting

Script for parsing directories one level and finding directories older than n days

Hello all, Here's the deal...I have one directory with many subdirs and files. What I want to find out is who is keeping old files and directories...say files and dirs that they didn't use since a number of n days, only one level under the initial dir. Output to a file. A script for... (5 Replies)
Discussion started by: ejianu
5 Replies

6. Red Hat

Find files older than 30 days in directories and delete them

Hi, I have dummies questions: My script here can find the files in any directories older than 30 days then it will delete the files but not the directories. I would like to also be able to delete the directories that hold old files more than 30 days not just the files itself. find . -type f... (2 Replies)
Discussion started by: lamoul
2 Replies

7. Shell Programming and Scripting

Zipping files older than one month

I have to zip all files older than a month within a directory. I have to archive them using the file extension I have .dat, .csv ,.cnt files within the directory. I used the following command It doesnt work find /path/*.dat -mtime +30 This command doesnot display .dat files older than a... (2 Replies)
Discussion started by: ramky79
2 Replies

8. HP-UX

Command for delete the directories which are older than 7 days

Hi, My requirement is need to delete the directories (Including files also) which are older than 7 days. So I used below command in one script (script takes 2 input parameters) #$1 - Path of the directory from where we have to delete the directories.# #$2 - Number of days older... (1 Reply)
Discussion started by: sridhar sivakot
1 Replies

9. UNIX for Dummies Questions & Answers

deleting older directories

how can we delete directories older than 6 months (9 Replies)
Discussion started by: dnat
9 Replies
Login or Register to Ask a Question