Delete 6 months old files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Delete 6 months old files
# 1  
Old 08-29-2008
Delete 6 months old files

Hi,

Iam trying to delete 6 months old files.
Iam using the following script

-ctime +190 -type f -exec echo rm {} \;
Iam getting an error saying -ctime not found.


# 2  
Old 08-29-2008
Code:
-ctime +190 -type f -exec echo rm {} \;

These are options of the find command, it should be something like:

Code:
find /your/path/ -ctime +190 -type f -exec rm {} \;

Try the command first without -exec rm {} \; to be shure you have the right output.

Regards
# 3  
Old 08-29-2008
Delete 6 monhs old data

Thanks,

I tried with the command given by you.Its working.

Can u please tell me the steps in shell scripts for removing the file after every 6 months auomatically.
# 4  
Old 09-02-2008
You can run this command with cron job, a link to a useful thread of Perderabo:

https://www.unix.com/answers-frequent...n-crontab.html

Regards
# 5  
Old 09-04-2008
Thanks,

Actually I am very new to Unix so please tell in which directory shall I create this cron and what exension should I give
# 6  
Old 09-04-2008
There are a lot of tutorials regarding cronjobs on the net, Google for cronjobs.

Regards
# 7  
Old 09-10-2008
Hi

I want a shell command to create a text file
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Deleting files and directory's older than 3 months

I have a qnap TS259 that is running ubuntu. Have successfully setup back scripts that are initiated by cron. I would like to create a couple scrypts that would operate on the recycle bins for both drives. Just want to be able to run the script manually that would walk through both directories... (13 Replies)
Discussion started by: mackconsult
13 Replies

2. Red Hat

Need Script to ZIP/SAVE & then DELETE Log file & DELETE ZIPS older than 12 months

ENVIROMENT Linux: Fedora Core release 1 (Yarrow) iPlanet: iPlanet-WebServer-Enterprise/6.0SP1 Log Path: /usr/iplanet/servers/https-company/logs I have iPlanet log rotation enabled rotating files on a daily basis. The rotated logs are NOT compressed & are taking up too much space. I... (7 Replies)
Discussion started by: zachs
7 Replies

3. Shell Programming and Scripting

Delete folder in a directory which are two months old

I need help. I have to create a script which will delete multiple directory (folders) that are two months old. Example, I have folders dated April, May, June and July. I have to delete folders April and May and retain June and July and as such that when the July month lapse, the folder June will be... (2 Replies)
Discussion started by: jasperux
2 Replies

4. Shell Programming and Scripting

Delete 2 months before old files when we get alarm directory size > 90%

Please Help me Question: - we manually moving/removing old files, when we are getting alarm as /dir1/dir2 size greater than 90%. we manually moving/removing old files and reduce the file size to less than 90% - I want to delete all 2months before old files once we get the thresh hold >= 90%... (3 Replies)
Discussion started by: piyus
3 Replies

5. Shell Programming and Scripting

gzip files older than 1 months

Hello, I want to gzip files in a folder in bulk i.e. all files older than 1 month should be in *.gz format. Could you please suggest how this can be achieved. Thanks. Regards, Alok (1 Reply)
Discussion started by: alok1301
1 Replies

6. UNIX for Dummies Questions & Answers

single line command to delete a 6 months old file

i had this scenario where i need to delete a file that is 6 months old which is no longer needed. basically the filename is in the format of PCARDDAILYmmddyyyy.txt where the mm is the month, dd is the day, and yyyy is the year. e.g. PCARDDAILY05262009.txt PCARDDAILY05252009.txt ... (6 Replies)
Discussion started by: wtolentino
6 Replies

7. Shell Programming and Scripting

Delete files older than 3 months.(read date from the name of the file)

Guys, My log files stored in the date format format below(log_20080714072942): TIMESTAMP=`date +%Y%m%d%H%M%S` LOG=/log/log_${TIMESTAMP}.log I'm looking for a shell script which deletes all files which is older than 3 months from today. Regards, Bhagat (3 Replies)
Discussion started by: bhagat.singh-j
3 Replies

8. UNIX for Advanced & Expert Users

Delete database table based on months using script.

HI All, Newbie here. I have a script which generates the tables in teradata database with time stamp like below.I want to add some more code to delete the archive tables which are 2months old. . $HOME/.profile t_name=$1 procdate=`date +%y%m%d` log_dir=$Folder/log tab=`echo... (0 Replies)
Discussion started by: Maverick79
0 Replies

9. UNIX for Dummies Questions & Answers

Last modification times of files less than 6 months old

How do I get the modification time for files less than 6 months old? (It seems for fles as old or older than this I get to see only the day,month and year. I tried the option -u but it gives me the last accessed time) (1 Reply)
Discussion started by: Abhishek Ghose
1 Replies

10. Shell Programming and Scripting

Listing files older than 2 months

A script or command to list files older than 2 months in a specified directory and remove it. (3 Replies)
Discussion started by: pbekal
3 Replies
Login or Register to Ask a Question