Command for delete the directories which are older than 7 days


 
Thread Tools Search this Thread
Operating Systems HP-UX Command for delete the directories which are older than 7 days
# 1  
Old 02-15-2008
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 directories to be deleted#



find $1 -type d -mtime +$2 -exec rm -r {} \;



The issue is this command is working fine, but when it deletes directory(Ex: XYZ directory) after some time(after 12 hrs) again XYZ gets created with different modification time and this directory is showing some size(Actually this directory files are deleting). So the question is why this directory is recreating? actually we do not want it.

Please let me know if any body have same experience in past.

Thanks
# 2  
Old 02-15-2008
The filesystem is not recreating the directory.
Possibilities:
1. some script or application recreates them with the same name
2. they are being restored from a tarball or "saveset" somewhere
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

Find command to search and delete files older than 1 days at a desired location

Hello All, Can someone please help me out in creating the find command to search and delete files older than 1 days at a desired location. Thanks in advance for your help. (3 Replies)
Discussion started by: Pandee
3 Replies

3. Shell Programming and Scripting

Delete files older than X days.

Hi All, I am using below code to delete files older than 2 days. In case if there are no files, I should log an error saying no files to delete. Please let me know, How I can achive this. find /path/*.xml -mtime +2 Thanks and Regards Nagaraja. (3 Replies)
Discussion started by: Nagaraja Akkiva
3 Replies

4. UNIX for Advanced & Expert Users

How to Remove 180 days older non-empty directories

Hi Gurus, I have command to delete more than 180days file. find /home/abc/ -name "CBST_*.txt*" -mtime +180 | xargs -n 100 rm -f Now I would like to delete more than 180days Non empty directory--What will be command? Following is non empty directory as instance CBST2010* (2 Replies)
Discussion started by: thepurple
2 Replies

5. 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

6. Shell Programming and Scripting

Delete folders older than 30 days

Dear all, i use incremental backup my data with .zip to my hard drive. what i need is i don't want the old .zip file older than 30 days. how to write a shell script automatically remove my external hard disc zip backup folders older than 30 days? Regards, (2 Replies)
Discussion started by: joneggk
2 Replies

7. 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

8. 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

9. Shell Programming and Scripting

Need to remove files older than 30 days except directories

Hi, I need to remove files (*.trc) which are older than 30 days from one location. My problem is there I do not want to visit any of the directories at that location. I want to search files at that particular location only (need to skip directorys at that location). maxdepth option is there... (6 Replies)
Discussion started by: malaymaru
6 Replies
Login or Register to Ask a Question