Find 3 months old log files and remove


 
Thread Tools Search this Thread
Operating Systems Solaris Find 3 months old log files and remove
# 8  
Old 05-22-2008
Tried find . -name *.log -mtime +90 -exec ls {}\;

Getting bad option xxxx.log file

$ find . -name *.log -mtime +90 -exec ls {}\;
find: bad option xxxx.log
find: path-list predicate-list
# 9  
Old 05-22-2008
oh my...! pls find your way around the syntax. u ed not post every single issue.
try this.
find <use_path> -name *.log -mtime +90 -exec ls
# 10  
Old 05-22-2008
this really should work. if not then I am not sure what to tell you.

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

i guess it is possible that there are so many files that the exec has problems. maybe try this:

find . -name "*.log" -mtime +90 -print

and see if that gets it.

btw, i always have to use quotes in my find statements when I use a wildcard. your mileage may vary.
# 11  
Old 05-22-2008
Pls make sure that you are using a space between {} and \;

Since you are dealing with special characters again - basically trying to look for all *.log.* files, you need to either use a \ or surround *.log.* with double quotes.....like this:

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

OR

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

(Make sure you are in the right directory by using pwd command).

Please get back and let us know if that worked....Cheers!
# 12  
Old 05-22-2008
Tried both no result


$ find . -name \*.log.\* -mtime +90 -exec ls {} \;
$
$ find . -name "*.log.*" -mtime +90 -exec ls {} \;
$
# 13  
Old 05-22-2008
sori cvdev I forgot to include the space as mentioned by hercu. am busy and was rushing with some stuff.. are u in the correct dir? use the wild card either before or aft the word .log and see.. use hercu's syntax.
# 14  
Old 05-22-2008
Thanks every one its working.
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