1834162 Members
2604 Online
110064 Solutions
New Discussion

file opened ?

 
SOLVED
Go to solution
Claudio_17
Frequent Advisor

file opened ?

Hi,

is possible with a unix command to know how a process has opened a file ?

This because I've a log file that increase in dimension and either with >logfile or cat /dev/null >logfile dimension remain the same and continue grow

Thanks
3 REPLIES 3
Patrick Wallek
Honored Contributor
Solution

Re: file opened ?

You can see who has a file open by doing:

# fuser -u /dir/filename

The only sure way to get the space released is to stop the process that is accessing the file, zero out the file the way you did, and then restart the process.
Zeev Schultz
Honored Contributor

Re: file opened ?

What do you mean "how a process has opened a file",like what flags (ReadOnly) etc?
Tusc can show system calls like open(),creat() etc,get it on http://hpux.cs.utah.edu/hppd/hpux/Sysadmin/tusc-7.5/.
Or lsof can show you files opened by proc. :
http://hpux.cs.utah.edu/hppd/hpux/Sysadmin/lsof-4.67/

Zeev
So computers don't think yet. At least not chess computers. - Seymour Cray
Cheryl Griffin
Honored Contributor

Re: file opened ?

You could also use lsof:
http://hpux.cs.utah.edu/hppd/hpux/Sysadmin/lsof-4.64/
# lsof /dev/null
OR
# lsof filename_here
"Downtime is a Crime."