1819804 Members
3042 Online
109607 Solutions
New Discussion юеВ

text file busy

 
SOLVED
Go to solution
Clint Gibler
Frequent Advisor

text file busy

I have a file located in the /tmp directory that I need to delete but when I try to rm it I get unable to remove text file busy if I can I want to avoid rebooting the server is there anyway to delete this file?
7 REPLIES 7
Alex Lavrov.
Honored Contributor
Solution

Re: text file busy

It means that some program uses it right now and you need to find out what is it:

lsof /path/to/file


you can get lsof here:

http://hpux.connect.org.uk/hppd/hpux/Sysadmin/lsof-4.76/

Alex.
I don't give a damn for a man that can only spell a word one way. (M. Twain)
Patrick Wallek
Honored Contributor

Re: text file busy

You can also try fuser.

# fuser -u /path/to/file

When you find the process that is using the file, you can then determine if you can safely kill the process so the file can be removed.
Jean-Luc Oudart
Honored Contributor

Re: text file busy

and if you don't have lsof
you can use "fuser -fu "

you will get the process(es) using the file.

man fuser

Regards
Jean-Luc
fiat lux
A. Clay Stephenson
Acclaimed Contributor

Re: text file busy

This actually means that the file you are trying to remove is an executable and is currently executing. "Text" in this context actually means "code"; i.e. the executable instructions. Do a ps -ef and you should see a process with the same name as the file you are trying to remove. It could also be a shared library that was installed in /tmp for test purposes.
If it ain't broke, I can fix that.
James R. Ferguson
Acclaimed Contributor

Re: text file busy

Hi Clint:

You could also try:

# fuser -fu filename

You might find that you can terminate the process using the file and thus proceed to remove it.

See the manpages for more information.

Regards!

...JRF...
Brian Vance
Advisor

Re: text file busy

If you have already determined that this file can be safely removed (ie it won't affect a critical application or process) then you can simply use

fuser -ku

This will send a kill signal to each process using the file.
doug hosking
Esteemed Contributor

Re: text file busy

Also note that even though you can't delete the file while it's still in use, you can at least still rename it. In some cases that may be sufficient. (For example, if you need to install a new version of a program, but can't because it's being executed by someone.) This is often done during the process of udating HP-UX.

Of course there can be security risks with keeping executables in publicly writable directories like /tmp, but that's a topic for another discussion.