- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- find option for not-open 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
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
02-21-2005 03:51 AM
02-21-2005 03:51 AM
My pesky users keep filling up /tmp (there are far too many to re-educate!).
They have kindly said that I can delete any files older than 10 days, but there are always some files in there which are being held open by processes.
fuser returns success if it runs successfully regardless of whether the file is open or not, and I could see no mention of detecting open files on the find man page.
I want to script a cron job to delete files older than 10 days, but exclude open files.
Any ideas?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2005 03:56 AM
02-21-2005 03:56 AM
Solution- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2005 03:58 AM
02-21-2005 03:58 AM
Re: find option for not-open files?
I suppose you will need lsof to see which files are opened by processes...
Ge and dowload it from your favorite Archive porting center
Good luck
All the best
Victor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2005 03:58 AM
02-21-2005 03:58 AM
Re: find option for not-open files?
congrats on the headgear!
The long term fix would be to set quotas on the users, which would stop them leaving files lying around.
It's difficult to spot individual open files unless you use lsof. You could try combining the find option for creation date > 10 days and modification time < 1 day, but this depends on how often the files get written to.
I'm sure somebody will have a perl script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2005 04:00 AM
02-21-2005 04:00 AM
Re: find option for not-open files?
# remove files in /tmp not modified in 10 days
find /tmp -mtime +10 -type f -exec rm {} \;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2005 09:12 AM
02-21-2005 09:12 AM
Re: find option for not-open files?
fuser
$? becomes the return code for the grep
Cheers
Steven
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2005 11:26 PM
02-21-2005 11:26 PM
Re: find option for not-open files?
Clay;
lsof looks like it will do the trick, thanks! Though I don't think I need the +D flag in this case (the man page was even harder to find than the binary!)
I know they shouldn't be doing it, but there are hundreds of them (clueless lusers, keyboard monkeys, cow-orkers, in-DUH-viduals, call 'em what you will) I'm outnumbered!
Victor; ditto on the lsof idea
Peter; (Aw, gee thanks!) Unfortunately, these users are all tippity-tappity-typing in LOADSAMONEY for The Company, so enforcing quotas is really not an option (never delete files, quota gets reached, can't create files, application hangs, money stops coming in, customers get P'd off, go elsewhere, "what happened?" "Well, Gordon set these quotas..." "Oh. I wish him luck in his next job.") Ditto for lsof, as these open files don't get written to for many days at a time and they belong to the main application for this box, that's why find -mtime doesn't cut it.
Robert; That's exactly the command I would normally use, but being paranoid, I ran it through fuser instead of rm, and found open files not written to for >10 days. Phew, that was close!
Steven; That looks good, and I really thought it would work, but as you can see from the output below, it returns inconsistent results and I have no idea why. It *should* have worked.
for file in *AH[DP]P
do
fuser $file
fuser $file 2>/dev/null | grep [0-9] >/dev/null
echo $?
done
B6161scrn.AHPP:
1
B6238scrn.AHPP:
1
CMD-R42054291832.AHPP:
1
REFUND_AHDP:
1
REFUND_AHPP:
1
bwdaemon.AHDP: 24746o
1
bwdaemon.AHPP: 24293o
1
clm_aud_07-FEB-05_AHDP:
1
clm_aud_07-FEB-05_AHPP:
1
clm_aud_08-FEB-05_AHDP:
1
clm_aud_08-FEB-05_AHPP:
1
clm_aud_09-FEB-05_AHDP:
1
clm_aud_09-FEB-05_AHPP:
1
etc. etc. etc.
blah blah blah...
clm_aud_20-FEB-05_AHDP:
1
clm_aud_20-FEB-05_AHPP:
1
clm_aud_21-FEB-05_AHDP:
1
clm_aud_21-FEB-05_AHPP:
1
pms_errAHDP:
1
pms_errAHPP:
1
qasdaemon.AHDP: 24741o 24747o
1
qasdaemon.AHPP: 10984o 11013o
0
strm_errAHDP:
1
strm_errAHPP:
1
========
Go figure :o/
Thanks again to all
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2005 11:27 PM
02-21-2005 11:27 PM