remove a file after 30 days


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting remove a file after 30 days
# 1  
Old 10-26-2007
remove a file after 30 days

currently i am doing a project where in i am creating files everyday with a name xyz_date for e.g. xyz_20071010,xyz_20071011 ... in this fashion.so at a particular point of time i need only 31 days of data.suppose we are executing the code today then we will have only 31 days data present and 32day's data(file) will be removed.
at a particular date i need only files with today() and today()-31.today()-32 will be removed.how can i write such a script.
# 2  
Old 10-26-2007
Quote:
Originally Posted by dr46014
currently i am doing a project where in i am creating files everyday with a name xyz_date for e.g. xyz_20071010,xyz_20071011 ... in this fashion.so at a particular point of time i need only 31 days of data.suppose we are executing the code today then we will have only 31 days data present and 32day's data(file) will be removed.
at a particular date i need only files with today() and today()-31.today()-32 will be removed.how can i write such a script.
Something like
Code:
find . -type f -mtime +31 -exec rm -f {} \;

# 3  
Old 10-26-2007
Quote:
Originally Posted by Radar
Something like
Code:
find . -type f -mtime +31 -exec rm -f {} \;

sorry friend coundnot get the code..
how can it find the path where the files are located and the format is YYYYMMDD.the naming convention of the file is
dab_unload_20071022
dab_unload_20071023
if we are running it on 24 the then 20071024 - 32 date should be removed..please explain a bit detail
# 4  
Old 10-26-2007
i have another doubt how can we find only the file names in another file located in a different path.means past 30 days file names i need in another path.suppose today is 25-oct-2007 then i need files from 26th sep to 25 th oct.
the names should be
dab_unload_20071025
dab_unload_20071024
...
dab_unload_20070925
# 5  
Old 10-26-2007
Code:
find /path/to/files -type f -name "dab_unload*" -mtime +31 -exec rm -f {} \;

# 6  
Old 11-09-2007
this script only removes the content of the file..but the file remains as it is.please help me how can i remove the total file
# 7  
Old 11-09-2007
sorry....my file was empty...
this code is not working...my req is to delete a file DAB_Unld_20071109 .
if today is 9th Nov then remove it,,
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Remove lines older than 30 days

Hi Experts/Gurus, Is there a way to remove lines in a file that are older than x days (i.e. 30 days) based on the date stamp in the first column? Example. $ date Sat Jan 11 14:12:06 EDT 2014 $cat sample.txt 10-10-2013 09:00:01 AM|Line test 1234567 16-10-2013 08:30:00 AM|Line test... (6 Replies)
Discussion started by: brichigo
6 Replies

2. Shell Programming and Scripting

Remove files older than 2 days.

Hi All, I am new to the scripting and using solaris 10 OS. Please suggest me from the below script which modifications need to be done to delete the files more that 2days older. Current script is deleting existing file. # Remove old explorer runs if needed DIR=`dirname ${EXP_TARGET}` if ... (2 Replies)
Discussion started by: Navkreddy
2 Replies

3. Shell Programming and Scripting

[Solved] Remove file older than 90 days

I have crontab job a tar file to a directory ( tar -cvf /tmp/backup/or.`date +%m%d%y`. /ora/db/* ) , it will do it every day . Now I don't want to keep too much files , I just want to keep the file for 90 days , can advise if I want to remove the backup file which are elder than 90 days , can... (1 Reply)
Discussion started by: ust3
1 Replies

4. Shell Programming and Scripting

How to remove the logs more than 5 days old

All, How to remove the logs that are more than 5 days old from a particular folder. Help will be highly appreciated. Regards Oracle User (2 Replies)
Discussion started by: Oracle_User
2 Replies

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

6. Shell Programming and Scripting

script to remove files older than 60 days

Hi I need help in the script which looks at a contorl file which has a list of file names like xxxx.12345 and I want to take only xxxxx and search in a specific directory and remove the file if its older than 60 days I have written something like this.. but seems to be wrong... (1 Reply)
Discussion started by: antointoronto
1 Replies

7. Shell Programming and Scripting

How can i remove the files generated on 10 days before!!!

Dear Friends! i am wirking on the IBM AIX version 5.3. and i wrote a script to delete the files whicha re generated on 10 days before to the present day. but iam not able to delete the files with the below script so please check and correct me. dt=`TZ=aaa480 date +%d`... (2 Replies)
Discussion started by: innamuri.ravi
2 Replies

8. Shell Programming and Scripting

How to tar, compress and remove files older than two days

Hi, I'm Eddy from Belgium and I've the following problem. I try to write a ksh script in AIX to tar, compress and remove the original *.wav files from the directory belgacom_sf_messages older than two days with the following commands. The problem is that I do not find a good combination... (4 Replies)
Discussion started by: edr
4 Replies

9. Shell Programming and Scripting

Remove files which created date before 10 days on HP-UX

Hi All, Could you please let me know if there is any one can help to create a shell script to remove some files which is the created date for them greate than 10 days (sysdate-10) Please try to email me on email removed Thanks in advance, Murad (1 Reply)
Discussion started by: murad_fayez
1 Replies

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