- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Question about deleting files by date
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2005 11:34 PM
06-16-2005 11:34 PM
Question about deleting files by date
Thanks, Kevin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2005 11:37 PM
06-16-2005 11:37 PM
Re: Question about deleting files by date
rm does not have a option for this.
My suggestions would be to use find -newer
You can then use the exec part to remove the files.
man find should get you started.
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2005 11:43 PM
06-16-2005 11:43 PM
Re: Question about deleting files by date
find /start_dir -type f -mtime +10 |xargs rm
There are good examples in the find man page.
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2005 11:44 PM
06-16-2005 11:44 PM
Re: Question about deleting files by date
touch
find
or you can use,
find
-mtime is used to check modified time over 10 days.
hth.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2005 12:10 AM
06-17-2005 12:10 AM
Re: Question about deleting files by date
I can't work with the directory on FTP. Reflections just goes kaput. So there is no way in unix to delete files in a directory older than a certain date? I need to keep some of the files so users can view past logs of past requests, otherwise I'd just blow away the whole directory and recreate it.
Kevin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2005 12:11 AM
06-17-2005 12:11 AM
Re: Question about deleting files by date
find /someplace -type f -mtime -10 -exec rm {} \;
HOWEVER: if you run this command as root, you have the ability (with a spelling error) to destroy all files in the entire computer!! As an example, if you accdently type / someplace rather than /someplace (see the extra space?) then find locates all files in the / directory--on every mountpoint--in every directory--including NFS! So always run a test command by using echo first:
find /someplace -type f -mtime -10 -exec echo rm {} \;
Also, the default behavior for find is to descend into all subdirectories. If you're cleaning out a flat directory, no problem. Or if you are cleaning out everything in all subdirectories, the above is still OK. But if you don't want to pickup anything in sub-directories, you need to do two things: add the -only option (which prevents looking at any directories), and add the * after your pathname:
find /someplace/* -only -type f -mtime -10 -exec echo rm {} \;
-only is not quite as simple as it would seem. When find is given a directory name, the first test is on that starting directory (not the contents) and -only says "don't look in any directories" - including this one). So to get rid of files in a specific directory, you have to give find the list of files to examine. As with all shells, /
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2005 08:15 PM
06-19-2005 08:15 PM
Re: Question about deleting files by date
as Bill above explains :
find - finds the files
exec rm or xargs - removes the files
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2005 08:40 PM
06-19-2005 08:40 PM
Re: Question about deleting files by date
as the rest has mentioned, use the find command. besides the concurrent (log) logs, take note of the Oracle output (out) files as well, it grows very fast as well.
# find
u may like to write a script which deletes these files and run it as a cron.
also, last thing, u may also like to assign points to show your appreciation to those who have assisted u in finding your answers. 0 out of 28 (and counting) is not good.
regards.