- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Housekeeping of old files on HP-UX
Categories
Company
Local Language
Forums
Discussions
Knowledge Base
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Forums
Discussions
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
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
01-27-2006 05:24 PM
01-27-2006 05:24 PM
I need to remove files with mtime over 4 months inside a folder which contain over 40000 files in it.
This folder also contain 3 subfolders which also have over 30000 files.
Before I delete it, I have to provide the list of file to be delete and I use the following command in each folder to list out the name of file
find . -type f -mtime +120 -exec ls -l {} >> result \;
However, it is still running after 30 mins and not completed. It make the whole system response very slow and I have to stop it.
Please kindly help to provide some faster and better solution for my case ? Many Thanks.
Chung
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-27-2006 05:49 PM
01-27-2006 05:49 PM
Re: Housekeeping of old files on HP-UX
You can do the same job in bunches by specifying the file names with wild characters. Something like
#find . -name "*.dbf" -mtime +120 -exec ll {} \;
Like this it will list only the files with the names matching.
HTH,
Devender
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-27-2006 06:14 PM
01-27-2006 06:14 PM
Re: Housekeeping of old files on HP-UX
Thanks for the suggestion.There are only 5 types of files I can found in those folder.
But is it possible to limit the total number of output file when i run the command ?
Since my server is running slow and it have impact to the system performance if i delete all of them in same time , I can only set a cronjob to delete some old files ( say 2000 files ) every day, any idea ?
#find . -name "*.dbf" -mtime +120 -exec ll {} \;
Thanks,
Chung
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-27-2006 06:24 PM
01-27-2006 06:24 PM
Re: Housekeeping of old files on HP-UX
What does this do
#find . -name "*.dbf" -mtime +120 -exec ll {} \; |pg
Will it not limit the output to be only one page at a time. ALlthough if the server is so heavily loaded you could search for some off time (night) to do this sort of jobs.
Also as the you have only 5 types of files are the nsames as well same for those files ? Instead of extentions you could also try various starting names like
"a*.*"
"b*.*"
Can you attach the output of ll in that directory?
HTH,
Devender
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-27-2006 06:52 PM
01-27-2006 06:52 PM
Re: Housekeeping of old files on HP-UX
Sorry for misleading, i mean there exist 5 types of files with similar file name.
#find . -name "RevokeRequest*" -mtime +120 -exec ll {} \;
#find . -name "UploadRequest*" -mtime +120 -exec ll {} \;
However, only one of the folders have this pattern.Other folder contain different name with .zip format
Actually, I am planning to set a cronjob at night for this to avoid system performance.
Attached please find the some reuslt of ll in one of my folder.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-27-2006 06:55 PM
01-27-2006 06:55 PM
Re: Housekeeping of old files on HP-UX
Sorry for misleading, i mean there exist 5 types of files with similar file name.
#find . -name "RevokeRequest*" -mtime +120 -exec ll {} \;
#find . -name "UploadRequest*" -mtime +120 -exec ll {} \;
However, only one of the folders have this pattern.Other folder contain different name with .zip format
Actually, I am planning to set a cronjob at night for this to avoid system performance.
Attached please find the some reuslt of ll in one of my folder.
Thanks,
chung
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-27-2006 07:08 PM
01-27-2006 07:08 PM
Re: Housekeeping of old files on HP-UX
Sorry for misleading, i mean there exist 5 types of files with similar file name.
#find . -name "RevokeRequest*" -mtime +120 -exec ll {} \;
#find . -name "UploadRequest*" -mtime +120 -exec ll {} \;
However, only one of the folders have this pattern.Other folder contain different name with .zip format
Actually, I am planning to set a cronjob at night for this to avoid system performance.
Please find the below redult of ll in one of my folder.
some output of ll
-rw-rw-r-- 1 oracle oinstall 2576 Aug 9 21:12 ./RevokeRequest.2115603712460820.49695480.0809130351000.74
-rw-rw-r-- 1 oracle oinstall 2584 Aug 9 21:22 ./RevokeRequest.2115643440906802.98036990.0809131104000.74
-rw-rw-r-- 1 oracle oinstall 2598 Aug 9 21:22 ./UploadRequest.2115628945393296.21170640.0809131153000.74
-rw-rw-r-- 1 oracle oinstall 2573 Aug 9 21:42 ./UploadRequest.2115550562241390.44837920.0809133312000.74
-rw-rw-r-- 1 oracle oinstall 216 Aug 16 07:17 ./ReportWork.null.711601.1124147857917.8
-rw-rw-r-- 1 oracle oinstall 215 Aug 16 07:17 ./ReportWork.null.711602.1124147857918.8
-rw-rw-r-- 1 oracle oinstall 216 Aug 16 07:17 ./ReportWork.null.711600.1124147857916.8
-rw-rw-r-- 1 oracle oinstall 215 Aug 16 07:17 ./ReportWork.null.711599.1124147857912.4
-rw-rw-r-- 1 oracle oinstall 216 Aug 16 07:17 ./Schedule.null.711601.1124147857917.8
-rw-rw-r-- 1 oracle oinstall 215 Aug 16 07:17 ./Schedule.null.711602.1124147857918.8
-rw-rw-r-- 1 oracle oinstall 216 Aug 16 07:17 ./Schedule.null.711600.1124147857916.8
-rw-rw-r-- 1 oracle oinstall 215 Aug 16 07:17 ./Schedule.null.711599.1124147857912.4
Thanks,
chung
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-27-2006 07:09 PM
01-27-2006 07:09 PM
Re: Housekeeping of old files on HP-UX
Sorry for misleading, i mean there exist 5 types of files with similar file name.
#find . -name "RevokeRequest*" -mtime +120 -exec ll {} \;
#find . -name "UploadRequest*" -mtime +120 -exec ll {} \;
However, only one of the folders have this pattern.Other folder contain different name with .zip format
Actually, I am planning to set a cronjob at night for this to avoid system performance.
Attached please find the result of ll in one of my folder.
Thanks,
chung
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-27-2006 07:44 PM
01-27-2006 07:44 PM
SolutionYou could still differentiate these file as there is a number in file names which is different for all files. A complete listing would have given a better idea. Still you can do something like this
#find . -name "RevokeRequest.21156*" -mtime +120 -exec ll {} \;|wc -l
Note :wc -l to count the files listed.
#find . -name "UploadRequest..21155*" -mtime +120 -exec ll {} \;|wc -l
Also there are other files as well.
You can do this by cron but I do not suggest that as the process may consume all the resources due to some eventuality and could even cause a crash of application etc.
HTH,
Devender
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2006 02:03 AM
01-28-2006 02:03 AM
Re: Housekeeping of old files on HP-UX
You can greatly reduce the time your cleanup takes!
When you use '-exec' with 'find' you are spawning a new process for every file that is delivered to you! Process initiation, like birth, is a very, very intensive action.
The key to reducing the amount of work to do is to initiate one process to handle groups (or blocks) of data at a time. This is exactly what 'xargs' is designed to do.
# find . -xdev -type f -mtime +120 | xargs ls -l results.log1
Now, when you want to actually remove the files *and* would also like a trace of what was actually done, do:
# find . -xdev -type f -mtime +120 | xargs -t rm 2> results.log2
Note that the '-t' option to 'xargs' enables a trace of every command executed to be written to STDERR. Hence, note the redirection of file descriptor-2 to the log file.
Using 'xargs' instead of '-exec' will dramatically reduce your execution times!
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2006 02:20 AM
01-28-2006 02:20 AM
Re: Housekeeping of old files on HP-UX
find /dir -name "[aA-dD]*" -exec ll -d {} \; |xargs -t rm 2>>/dir/remove.log
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2006 02:56 AM
01-28-2006 02:56 AM
Re: Housekeeping of old files on HP-UX
Removing files in groups (e.g. [A-F], [G-K] etc.) as opposed to in one pass will not gain anything.
By breaking one 'find' into several, you will end up walking the same trees, and 'stat'ing the *same* files multiple times before they are ultimately removed.
The use of 'xargs' in lieu of '-exec' will result in your user's thanking you.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2006 12:13 AM
01-30-2006 12:13 AM
Re: Housekeeping of old files on HP-UX
now, what your problem is seems to be that the process slows down your system. just let it run, but renice it to begin with. it might even take longer to complete, but at least it will not interfere (much) with the rest of your system.
nice
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2006 07:03 AM
01-30-2006 07:03 AM
Re: Housekeeping of old files on HP-UX
* Optimize the find by using xargs instead of -exec
and
* Be nicer to the CPU with the "nice" command
A comment to Dirk's "nice" command.
For the command to really be nice to the system you would want to use a positive value!!!
Example:
nice 10 "command"
If you additionally put it to run in background it will be even slightly nicer.
nice 10 "command" &
An unsigned value increases the system nice value causing it to run at lower priority.
A negative value (less nice)=higher priority
Positive value = nicer :-))
because it get lower priority.
/2r