- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Remove Files
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
тАО03-24-2009 01:32 AM
тАО03-24-2009 01:32 AM
Remove Files
I want to delete the file which older then 30 days then would you please let me know the command.
Files are in /var/
OS HPUX 11.11
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-24-2009 01:53 AM
тАО03-24-2009 01:53 AM
Re: Remove Files
find /var/dirname -type f -mtime +30 -exec rm {} \;
Ganesh.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-24-2009 02:35 AM
тАО03-24-2009 02:35 AM
Re: Remove Files
The file which havn't been modified in last 30-days
# find /yourpath -xdev -type f -mtime +30 -exec rm -rf {} \;
Suraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-24-2009 02:46 AM
тАО03-24-2009 02:46 AM
Re: Remove Files
find has a parameter for file detection, called +mtime That means modify time.
You can also check create time with +ctime
find /location -type f -ctime +30 -exec rm {} \;
find /location -type f -mtime +30 -exec rm {} \;
This will work on files except those with open file handles on them
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-24-2009 03:45 AM
тАО03-24-2009 03:45 AM
Re: Remove Files
The number of times people equate 'ctime' to a creation time in UNIX is sad!
The 'ctime' is _NOT_ a creation time in UNIX!
Rather the 'ctime' represtents the last _change_ time for permisssions, owenerships and/or a name.
The 'ctime' _may_ coincidently be equivalent to the moment of creation (represented by the first instantiation of '-mtime'). Subsequent modifications to the file or directory's contents alter (update) the 'mtime'.
To find (and remove) files older than 30-days do:
# find /path -xdev -type f -mtime +30 -exec rm {} +
The '-xdev' prevents crossing mountpoints. The '-type f' specifies files only (not directories too). The '-mtime +30' says to look for things that are older than 30-days (where one day is 24-hours). The '-exec rm {} +' causes a 'rm' command to be run for an argument list generated. THe '+' terminator causes multiple arguments to be bundled to each command making the process run faster and spawn significantly less children (an expensive thing).
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-25-2009 12:49 AM
тАО03-25-2009 12:49 AM
Re: Remove Files
I agree with all propositions. Thanks James for your detail answer. I have a question for James. With the + sign at the end of command rm wil be executed one time with all arguments given by find ! How many argument can be given to rm ?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-25-2009 12:56 AM
тАО03-25-2009 12:56 AM
Re: Remove Files
Lots but it depends on the length of each one. ;-)
I'm not sure what the limit find uses. You could invoke a script to count them and their lengths.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-25-2009 03:52 AM
тАО03-25-2009 03:52 AM
Re: Remove Files
> How many argument can be given to rm?
To add to Dennis's answer, I suspect that 'find' assembles as large a list as possible, passes the list to the command (here, 'rm') and then assembles a new list until every object is satisfied.
Before the advent of the '+' terminator for such assembly, the way to gain performance, was to do:
# find /path -xdev -type f -mtime +30 | xargs rm
THis allowed 'xargs' to perform multiple argument assembly repetively until the arguments were exhausted, for as large a list as it could handle each time.
With 'xargs' should you wish to _control_ the number of arguments you pass (which is sometimes desired), you can add the -n' switch, like:
# find /path -xdev -type f -mtime +30 | xargs -n 10 rm
...which would bundle 10 arguments together for each 'rm' process that it was necessary to spawn.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-25-2009 04:12 AM
тАО03-25-2009 04:12 AM
Re: Remove Files
Be very, very careful!
There are a lot of very important files under /var , even with older dates, e.g. /var/adm/sw
Manually deleting files there will corrupt your system.
Hope this helps!
Regards
Torsten.
__________________________________________________
There are only 10 types of people in the world -
those who understand binary, and those who don't.
__________________________________________________
No support by private messages. Please ask the forum!
If you feel this was helpful please click the KUDOS! thumb below!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-25-2009 12:15 PM
тАО03-25-2009 12:15 PM
Re: Remove Files
Yes. The source says it starts with ARG_MAX (getconf _SC_ARG_MAX) around 2 Mb, then subtracts PATH_MAX and roughly the size of the current environment.