Computing.Net > Forums > Unix > delete old files

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

delete old files

Reply to Message Icon

Name: Junes
Date: October 6, 2006 at 06:31:08 Pacific
OS: sol
CPU/Ram: na
Product: na
Comment:

Can someone assist

I want to delete files in the following directory /usr/openv/java/logs/ which are more than 7 days old

-rw-r----- 1 root other 426 Sep 26 09:34 root.jnbSA.3929.log
-rw-r----- 1 root other 404 Sep 26 14:30 root.jnbSA.1165.log
-rw-r--r-- 1 root other 1283 Sep 27 15:47 root.jnbSA.1818.log
-rw-r--r-- 1 root other 403 Sep 27 15:50 root.jnbSA.2068.log
-rw-r----- 1 root other 57072 Sep 27 17:18 root.jnbSA.12028.log
-rw-r----- 1 root other 404 Sep 28 09:10 root.jnbSA.3762.log
-rw-r--r-- 1 root other 427 Sep 28 09:17 root.jnbSA.4579.log
-rw-r--r-- 1 root other 94409 Sep 29 14:09 root.jnbSA.22253.log
-rw-r----- 1 root other 1058 Oct 1 11:46 root.jnbSA.21843.log
-rw-r----- 1 root other 681 Oct 1 14:01 root.jnbSA.25458.log

The following does not work

find /usr/openv/java/logs -atime +4 -name "*.jnbSA.log*" -exec rm {} \;

King Regards

Junes



Sponsored Link
Ads by Google

Response Number 1
Name: James Boothe
Date: October 6, 2006 at 13:45:15 Pacific
Reply:

You need to use -mtime for age of file. The -atime option looks at last access date.

And your name pattern is not correct for your filenames.

find /usr/openv/java/logs -mtime +4 -name "*.jnbSA.*.log" -exec rm {} \;


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: delete old files

Deleting old files using ftp script www.computing.net/answers/unix/deleting-old-files-using-ftp-script/4257.html

Script to delete old files www.computing.net/answers/unix/script-to-delete-old-files/4094.html

Deleting old files www.computing.net/answers/unix/deleting-old-files/4621.html