- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: how to delete files which are olderthan 24 hou...
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
Discussions
Discussions
Discussions
Forums
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
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
тАО11-06-2004 01:49 AM
тАО11-06-2004 01:49 AM
how to delete files which are olderthan 24 hours
i have a shell script which deletes files which are olderthan 2 days.... how can I change this to delete files which are olderthan one day (24 hours)
i need a shell script to do that... in hpux 11i
thnx in advance...
--ram
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-06-2004 02:08 AM
тАО11-06-2004 02:08 AM
Re: how to delete files which are olderthan 24 hours
you can try this with a combination of touch and find command.
say the current time is 10 am Nov 6th, touch a file with a timestamp of 10am nov 5th
touch -t 200411051000 /tmp/testfile
Now use this file to ocheck on the timestamp of the other files in the directory where you want to look for files more than 24 hours old.
find /your_dir -type f !-newer /tmp/testfile -exec ll {}\;
to delete these files
find /your_dir -type f !-newer /tmp/testfile -exec rm {}\;
Hope this helps.
regds
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-06-2004 02:20 AM
тАО11-06-2004 02:20 AM
Re: how to delete files which are olderthan 24 hours
So why don't you share (attach as txt?) with us the chunk of the script that you suspect selects the files now.
A reader may be able to adapt the existing script to the new requirement.
btw... for some quick & dirty cleanup scripts it is enough to just do
find $target -mtime +1 -exec rm {} \;
Be sure to check 'man find' for the various time selections you can make and details on how to specify older vs newer and so on.
hth,
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-06-2004 03:02 AM
тАО11-06-2004 03:02 AM
Re: how to delete files which are olderthan 24 hours
find
And,
if you are having script then, just change 2 day to 1 day :)
HTH.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-06-2004 05:14 PM
тАО11-06-2004 05:14 PM
Re: how to delete files which are olderthan 24 hours
use your script ;-)
example
find /opt/oracle/SID/bdump -mtime +1 -exec rm{} \;
br Jan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-06-2004 05:31 PM
тАО11-06-2004 05:31 PM
Re: how to delete files which are olderthan 24 hours
# find /dir -type f -mtime +1 -exec rm -i {} \;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-06-2004 08:01 PM
тАО11-06-2004 08:01 PM
Re: how to delete files which are olderthan 24 hours
thnx a lot.... for ur help.... one last and small doubt... if i want to delete the files which are olderthan 12 hours how can I do it.....?
thnx in advance...
--ram
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-06-2004 11:19 PM
тАО11-06-2004 11:19 PM
Re: how to delete files which are olderthan 24 hours
# touch -t
find . !-newer /tmp/ref -type f -exec rm {}\;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-07-2004 05:10 AM
тАО11-07-2004 05:10 AM
Re: how to delete files which are olderthan 24 hours
The find, just with time becomes too coarse.
The find with -newer become more interesting.
You may also want to check out the perl -M operator to give an age to work with. The same perl script could do the finding ('glob') and the delete (unlink).
Howeverm, now that you are talking about such rapid turnaround on your files I'm starting to think this may be about log / trace / eds / temp files for a specific application which needs to be reigned in somewhat.
You may want to consider a build in method versus after the fact cleanup. For example, maybe those files are all created in a specific directory? How about making that directory a softlink to a time-stamped directory? Every hour, on the hour, or every 6 hours, you create a fresh directory and flip the soft-link to point to the new directory. Once that is done you delete the directory that corresponds with the current delete interval you need to maintain.
Or... you could look at the space used / left and delete older directory untill the space need is acceptable instead of blindly deleting older files whether you need the space or not.
[those directories could have a date+time encoded in the name YYMMDDHHMM, or could just have numeric sequence number as name.]
Just thinking out aloud...
hth.
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-07-2004 06:34 PM
тАО11-07-2004 06:34 PM
Re: how to delete files which are olderthan 24 hours
#crontab -e
* 6 * * * /testscript
and the testscript contant is
find / -atime +1 -exec rm {} \;