Script for automatic deletion of old folder


 
Thread Tools Search this Thread
Operating Systems Solaris Script for automatic deletion of old folder
# 1  
Old 09-03-2008
Error Script for automatic deletion of old folder

Hi,
I have a folder with limited space. So i have to delete folder which are more than 5 days old automatically.
So my script should be like delete the folder more than 5 days old.
Can someone help me to generate a script for this.

Thank you...

Cheer
Summer
# 2  
Old 09-03-2008
Code:
find . -type d -mtime +5 -exec rm -rf {} \;

(untested, so try it someplace safe first)
# 3  
Old 09-03-2008
ok thank you.. i will try it out.

Summer
# 4  
Old 09-03-2008
Hi

Thank you very much... it works^^

Summer
# 5  
Old 09-04-2008
Excellent! Smilie fyi, you can switch the '-type d' flag to be '-type f' to search for files instead of folders if you wish.
# 6  
Old 09-04-2008
great!! thanks alot
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Request for Shell script to move files from Subfolder to Parent folder and delete sub folder

Hi Team, I am new to shell script and there is a requirement where files should be moved from Subfolder to parent folder. Eg: parent folder --> /Interface/data/test/IN Sub folder -->/Interface/data/test/IN/Invoice20180607233338 Subfolder will be always with timestamp... (6 Replies)
Discussion started by: srivarun15
6 Replies

2. Shell Programming and Scripting

Forceful deletion of folder not working

Hello, I am trying to delete a folder forcefully using the command: rm -rf <dir name> but its still asking for confirmation. Please help me out with a solution. scenario: bash-3.00$ chmod 777 gcc-3.4.2 bash-3.00$ bash-3.00$ bash-3.00$ bash-3.00$ rm -rf gcc-3.4.2/ rm: examine files in... (3 Replies)
Discussion started by: harishisnow
3 Replies

3. Shell Programming and Scripting

Deletion and recreation within a script

All printers are created on the PROD server and my script must pick up the differences in a diffs.txt file delete the printer if exist on the DEV server recreate it as it currently stands on the PROD server from the diffs.txt The following script I have, should allow me in synching the local... (0 Replies)
Discussion started by: ggoliath
0 Replies

4. Shell Programming and Scripting

file and directory deletion script

I saw many post about this but could not find a specific answer to this question. i have the following code find . -depth -name "$FILEEXT" -ctime -30 -exec rm {} \; when i type ./deletefiles.sh *.txt for example, it will find all the txt files less than 30 days old and delete them. my... (9 Replies)
Discussion started by: new2learn09
9 Replies

5. Shell Programming and Scripting

Unique Directory and Folder Deletion Script

Ok, so I just got charged with the task of deleting some 300 user folders in a FTP server to free up some space. I managed to grep and cut the list of user folders to delete into a list of one user folder per line. Example: bob00 jane01 sue03 In the home folder, there are folders a-z, and... (5 Replies)
Discussion started by: b4sher
5 Replies

6. Shell Programming and Scripting

script for Finding files in a folder and copying to another folder

Hi all, I have a folder '/samplefolder' in which i have some files like data0.txt, data1.txt and data2.txt. I have to search the folder for existence of the file data0.txt first and if found have to copy it to some other file; next i have to search the folder for existence of file... (5 Replies)
Discussion started by: satish2712
5 Replies

7. UNIX for Dummies Questions & Answers

script for deletion using wildcards

find ./ -name t\* | sed "s@^./@@" > .filestobedeleted j=$(wc -l < .filestobedeleted) typeset -i cnt=0 typeset -i i=0 while read line do myarray=$line ((cnt = cnt + 1)) done < .filestobedeleted while (1 Reply)
Discussion started by: aishu
1 Replies

8. Shell Programming and Scripting

Finding Hidden files and protecting the folder containing hidden files from deletion

Hi. I have a script which is deleting files with a particular extension and older than 45 days.The code is: find <path> -name "<filename_pattern>" -mtime +45 -exec rm {} \; But the problem is that some important files are also getting deleted.To prevent this I have decide to make a dummy... (4 Replies)
Discussion started by: pochaw
4 Replies

9. Solaris

Script for automatic deletion of trash file of mail server

Hi, I have a mail server with limited space and operating system is sun solaris 8 (sparc). I do not have provisions to increase the space for home directory. So i have to delete files from /home/username/mail/trash which are more than 10 days old automatically. So my script should be like... (1 Reply)
Discussion started by: crown2100bd
1 Replies

10. Shell Programming and Scripting

Script for automatic deletion of old files

Hi, I have a folder with limited space. I do not have provisions to increase the space for this folder. So i have to delete files which are more than 1 month old automatically. But, i need to maintain the files created by 4 users and delete all the other files automatically which is more than 1... (4 Replies)
Discussion started by: vivek_scv
4 Replies
Login or Register to Ask a Question