Operating System - HP-UX
1752402 Members
6348 Online
108788 Solutions
New Discussion юеВ

Determing when a file is (no longer) being accessed

 
SOLVED
Go to solution
Phil_2
Occasional Advisor

Determing when a file is (no longer) being accessed

I know, I Know - fuser. Well, we have just removed root access from some of our more trusted users, and lo and behold, some of their scripts no longer run properly. They were using 'fuser' to check file access before archiving a log file.
My Question: What other method can be used to determine if a file is no longer being accessed? (Something besides 'fuser'...)

My Best to all,
Phil
Whether you think you can or you can't, you're right!
6 REPLIES 6
Jeff Schussele
Honored Contributor

Re: Determing when a file is (no longer) being accessed

Hi Phil

lsof immediately comes to mind & outta the box it IS executable by others.

Rgds,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
Kenneth Platz
Esteemed Contributor

Re: Determing when a file is (no longer) being accessed

You can use the following:

find /tmp -atime +7 -print

That will find all files and directories in /tmp that were last accessed 7 or more days ago.
I think, therefore I am... I think!
Robert-Jan Goossens
Honored Contributor
Solution

Re: Determing when a file is (no longer) being accessed

Helen French
Honored Contributor

Re: Determing when a file is (no longer) being accessed

Use 'find' command with -atime or -mtime or -ctime or -newer options. Read man pages for more information about these:

# man find

Eg:

# find /var -type f -mtime -2 -exec ll {} \;

this will list all files which were modified with in the last 2 days.
Life is a promise, fulfill it!
Pete Randall
Outstanding Contributor

Re: Determing when a file is (no longer) being accessed

Phil,

I'm not sure whether lsof would require root privileges as well but you could try it:

11i/64bit:
http://the-other.wiretapped.net/security/host-security/lsof/binaries/hpux/B.11.00/vxfs/64/9000_785/

11.0/64bit:
http://the-other.wiretapped.net/security/host-security/lsof/binaries/hpux/B.11.11/

11.x/32bit
http://hpux.cs.utah.edu/hppd/hpux/Sysadmin/lsof-4.70/


Your other option is to look into sudo to distribute root privileges to other users:
http://hpux.cs.utah.edu/hppd/hpux/Sysadmin/sudo-1.6.7p5/


Pete


Pete
Phil_2
Occasional Advisor

Re: Determing when a file is (no longer) being accessed

Thanks to all of you. The "lsof" command will probably work the best.

I have used the 'find' command, but not to the granularity required here.
The file in question is an Oracle archive log, and the need is to determine when it can be gzip'd after access by the DB is complete.

Thanks to all, please don't hesitate to add more to this thread if you think of anything else.

Thanks again.
Phil
Whether you think you can or you can't, you're right!