cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with open files

Manoj Misra
Advisor

Problem with open files

Hi All,

During the systen checkup (N class HP 11). I deleted some files to reduce the file system size but that didn't worked. I belive one of those files remained open even after deleating.

How can I find the process associated to that open file. Or which files are currently in open status(but not visible).
11 REPLIES
Trond Haugen
Honored Contributor

Re: Problem with open files

Generally rather than deleting a file you should trunkate it with '> file2trunkate'. This will "keep the file but set it to zero".
The best way out of it now is to reboot.

Regards,
Trond
James R. Ferguson
Acclaimed Contributor

Re: Problem with open files

Hi:

An open file can be deleted but the space that it occupied will *not* be returned until all processes using the file finish.

Regards!

...JRF...

Manoj Misra
Advisor

Re: Problem with open files

Is there any way to findout what all the files are open.
Or which processes are using those files.???

Regards
Manoj
harry d brown jr
Honored Contributor

Re: Problem with open files


Yes,

http://hpux.cs.utah.edu/hppd/hpux/Sysadmin/lsof-4.64/


live free or die
harry
Live Free or Die
Rich Wright
Trusted Contributor

Re: Problem with open files

If you have Glance+ you can try to find them process by process.
First on the global screen, look for suspicious processes. High CPU, High I/O, etc.
Then select "s" option and enter the PID.
Then select the "F" option to see it's open files.

Rich
Paula J Frazer-Campbell
Honored Contributor

Re: Problem with open files

Hi

Cd to dir

fuser -u *

list list all

fuser -u
will do the named file

fuser -k

Will kill the connection.

See man fuser

Ps must be root to run fuser

HTH

Paula
If you can spell SysAdmin then you is one - anon
Judy Traynor
Valued Contributor

Re: Problem with open files

fuser filename will list the pid associated with open files.

fuser */* works to see which files are open 2 levels down.

The result will be the filename with the pid, once you get pid you can ps -ef it.
Sail With the Wind
Paula J Frazer-Campbell
Honored Contributor

Re: Problem with open files

Hi

I missed the file not being visable.

cd to the dir immediatly under where the files were/are

then fuser -u

This will return PIDs - do a ps -ef and trace each one until you find it.

If the dir should not be in use then an fuser -k can be used - BUT be 100% sure.

Paula
If you can spell SysAdmin then you is one - anon
Bill Thorsteinson
Honored Contributor

Re: Problem with open files

If you where killing off log files, then try sending a HUP
signal to the daemon that had the file open. This should
cause it to close and reopen its log files. For /var/adm
this is likely the syslog
daemon.

To find the PID
ps -ef | grep sys

To kill the daemon
kill -HUP _pid_

Consider installing logrotate
to rotate logs on a reasonable
frequency. It can be set to compress old log files.
Shannon Petry
Honored Contributor

Re: Problem with open files

If the file was successfully deleted, then you have no choice but to reboot. Kernel trace will not show the open files partent, but only the open file itself. lsof may be able to find it for you, but since lsof uses kernel tracing Im not sure if it will find it.

Like someone else mentioned, use a file zeroing technique in the future to avoid these problems.

I.E.
cat /dev/null >filename
#use with caution!

Regards,
Shannon
Microsoft. When do you want a virus today?
Anand Hotchandani
Occasional Visitor

Re: Problem with open files

Hi Manoj,

For finding the openfiles in a system download a utility "lsof". This utility will lists you no of open files.

lsof: List open files.

I have this utility mail me and send you utility through mail.

Regards
Anand