Why a dot file cannot be deleted after running a Java program?

W

www

Hi,

I have noticed that after running my Java program, there is a dot file
that cannot be deleted. (I use linux). Following is the screen shot:

$ls -a
.. .. .nfs009da645000007c3
$rm .nfs009da645000007c3
rm: remove regular file `.nfs009da645000007c3'? y
rm: cannot remove `.nfs009da645000007c3': Device or resource busy

I guess that I didn't close some PrintWriter or what. The Java program
ends normally. Can you give me some suggestions?

Thank you very much.
 
L

Laurent D.A.M. MENTEN

www a écrit :
Hi,

I have noticed that after running my Java program, there is a dot file
that cannot be deleted. (I use linux). Following is the screen shot:

$ls -a
. .. .nfs009da645000007c3
$rm .nfs009da645000007c3
rm: remove regular file `.nfs009da645000007c3'? y
rm: cannot remove `.nfs009da645000007c3': Device or resource busy

I guess that I didn't close some PrintWriter or what. The Java program
ends normally. Can you give me some suggestions?

Thank you very much.

Have you tried the lsof to find if your file is still used by some
process? This command lists the open files, see the manpage for flags
details.
 
D

Daniel Pitts

Hi,

I have noticed that after running my Java program, there is a dot file
that cannot be deleted. (I use linux). Following is the screen shot:

$ls -a
. .. .nfs009da645000007c3
$rm .nfs009da645000007c3
rm: remove regular file `.nfs009da645000007c3'? y
rm: cannot remove `.nfs009da645000007c3': Device or resource busy

I guess that I didn't close some PrintWriter or what. The Java program
ends normally. Can you give me some suggestions?

Thank you very much.

Are you sure that it was your Java program that created that file, and
not some other process (including your IDE)?
You might also do an ls -al to see the permissions and size of the
file.
 
R

Roedy Green

Hi,

I have noticed that after running my Java program, there is a dot file
that cannot be deleted. (I use linux). Following is the screen shot:

$ls -a
. .. .nfs009da645000007c3
$rm .nfs009da645000007c3
rm: remove regular file `.nfs009da645000007c3'? y
rm: cannot remove `.nfs009da645000007c3': Device or resource busy

I guess that I didn't close some PrintWriter or what. The Java program
ends normally. Can you give me some suggestions?

Thank you very much.

In windows the problem is either the file attributes, the owner or the
file is in use. Presumably Linux has analogs.

Here is something simple to try that probably won't work. Try
renaming the file so it does not start with the . which means hidden.
 
D

Douglas Wells

I have noticed that after running my Java program, there is a dot file
that cannot be deleted. (I use linux). Following is the screen shot:

$ls -a
. .. .nfs009da645000007c3
$rm .nfs009da645000007c3
rm: remove regular file `.nfs009da645000007c3'? y
rm: cannot remove `.nfs009da645000007c3': Device or resource busy

I guess that I didn't close some PrintWriter or what. The Java program
ends normally. Can you give me some suggestions?

This file is an artifact of the NFS (network) file system that you
are almost certainly using. This type of file entry is created
when a normal file is deleted (unlinked) while some process
(presuming your Java program) has it open. This is a common
strategy for creating of temporary files by UNIX programs. If you
were using the file on a local file system, the removal would
simply result in a "file" that still existed but did not have a
file system entry. The advantage of this strategy is that the OS
will remove the "file" when the file is closed -- even if the close
is caused by an abnormal exit.

NFS was designed as a "state-less" file system. This has several
advantages, but one of the disadvantages is that is doesn't handle
"state-ful" operations. This type of removal requires the retention
of the knowledge that the original file system entry has been
removed, but the data must still be retained. NFS handles this
by renaming the original file to the form ".nfs<something>" instead
of actually removing it.

It should go away when the process completes, but if it doesn't
for some reason, there are a couple of options. On many/most
systems that serve NFS clients, there is a daemon job that sweeps
the file systems and deletes such files after a couple of days.
If you are sure that no programs are still active that might access
this file, it is safe for you to delete it yourself -- although
if you do this while some process still have the file open, you
will simply iterate on the creation of the strangely named files.
You probably also would be able to delete it from a program running
on the server system.

Just a little more detail if you're interested: The use case to
consider here is that you have an NFS-mounted file open that you
have removed. Now consider that the server is rebooted for whatever
reason. Your client-side file system still needs to be able to
reopen the file, and it does so by using the ".nfs<something>"
form of name.

Here are some random references that Google came up witH;
http://www.cs.indiana.edu/Facilities/FAQ/General/dotnfs.html
http://www.seas.upenn.edu/cets/answers/nfs-files.html

- dmw
 
W

www

Thank you for all your responses.

The "problem" disappeared today. I have run into this problem yesterday
twice. But today, there is no such dot file left after running the Java
program. I don't know if this has to do with our system administrator
working on the linux system or not.

Thank you all.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top