Find 3 months old log files and remove


 
Thread Tools Search this Thread
Operating Systems Solaris Find 3 months old log files and remove
# 1  
Old 05-22-2008
Find 3 months old log files and remove

HI

I HAVE LOG FILES IN THIS FORMAT

XXX.log.20080509215745
XXX.log.20080209205745
XXX.log.20080301785745
XXX.log.20080109155745
XXX.log.20080409115745
XXX.log.20080309105745

I NEED TO FIND THE FILES FROM 3 MONTHS OLD AND REMOVE

PLEASE HELP

THANKS,
# 2  
Old 05-22-2008
find /yourdir -type f -name "filename.*" -mtime +90 -exec rm {} \;
# 3  
Old 05-22-2008
#find . -name *.log* -mtime +90 -exec rm {} \;
but before that get a listing to see what you are about to delete
#find . -name *.log.* -mtime +90 -exec ls -tl {} \;
Search and remove is a potentially dangerous command make sure you are in the directory where you are deleting files find . means present directory
# 4  
Old 05-22-2008
Thanks for the reply

I tried the command

find . -name *.log.* -mtime +90 -exec ls -tl {} \;

getting error Arg list too long

bash-2.03$ find . -name *.log.* -mtime +90 -exec ls -tl {} \;
bash: /usr/bin/find: Arg list too long

Thanks,
# 5  
Old 05-22-2008
your bash could be causing the problem or your dir might be over-growing
# 6  
Old 05-22-2008
Tried with out bash

$ find . -name *.log.* -mtime +90 -exec ls -tl {} \;
ksh: /usr/bin/find: arg list too long

getting the same error

Directory has different type of files
like

*.log
*.log.20080502124557
# 7  
Old 05-22-2008
try this?
$ find . -name *.log -mtime +90 -exec ls {}\;
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Command to Count the files which is Older than 3 months?

Hi Gurus the count of files in a particular Directory... ls -lrth | grep -c ^- can any one share the command to Count the files which is Older than 3 months So please help me out in this Thanks in Advance (2 Replies)
Discussion started by: SeenuGuddu
2 Replies

2. Shell Programming and Scripting

need a code for moving the log files older than 2 months

Hi Viewer, I need logic code for moving the logs files from one directory to another directory. source :/xxxxxx/ xxxxxx / xxxxxx / xxxxxx / log --- under log directory we have so many files from last two years Here I need to check the files older than two months and I need to move in... (5 Replies)
Discussion started by: munna_su
5 Replies

3. Shell Programming and Scripting

Some manipulations with files and folders. (loop, find, create and remove)

Hello! I need to realize such task. 1. In my user's home dir I have folder1; 2. In folder1 I have some (various count) subfolders with random names; 3. In these subfolders I have one file anyname.pdf (various name in each subfolder) and file content.txt (constant name in each subfolder) ##... (7 Replies)
Discussion started by: optik77
7 Replies

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

5. Shell Programming and Scripting

How to find the password in the logs and remove the log which indicate it.

I want to crypt my files but as you know I have to write the password in the xterm...as you know there is a log where every thing I write in the xterm are store on it..how can I get the logs and delete the record which indicate my password..or prevent the xterm from storing my password in the... (2 Replies)
Discussion started by: ahmad.diab
2 Replies

6. Shell Programming and Scripting

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. (6 Replies)
Discussion started by: Sompalle Jalaja
6 Replies

7. Shell Programming and Scripting

Remove/Find files based on position pattern

Hi All, Please help me to find or remove files based on position based search pattern. file1.txt: aaabbbccc dddeeefff iiijjjkkk file2.txt: lllmmmnnn ooopppqqq rrrsssttt file3.txt: uuuvvvwww xxxeeeyyy zzzcccooo From the above files, I like to delete the files that have "eee"... (1 Reply)
Discussion started by: kumarn
1 Replies

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

9. UNIX for Dummies Questions & Answers

Find files older than 5 days and remove tem after listing

need help with this ... Find files older than 5 days and remove tem after listing list "test" file older than 5 days and then remove them (1 Reply)
Discussion started by: ypatel6871
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