Removing ".nfs" files

Hello,

I have a critical client-server application. I try to import a file from the local machine on to the server and open it (on the server). I can open it, but after this, when i try to open some other file on the server itself without saving this imported file, a .nfs file is being created.
This .nfs file will not be removed untill i close my application, but i am not supposed to close. Earlier i didn't have this problem. Now suddenly it started coming.

If anyone has come across anything like this, please help me in getting this sorted out.

I searched the web also, but nobody listed any solution nor the cause of this.

Thanks,
Jay.

In unix, it is ok to create a file, then unlink it, and continue to read and write to it. When you remove the last link to a file, it becomes a file with zero names. But the inode will not be freed until all processes close it. This is often done with temporary files. If the process aborts, the file will go with it.

It is hard to implement this in an nfs environment. If a nfs client gets a request from a local process to delete a file, it checks to see if any local processes still have that file open, if so, it renames the file to a .nfs<something> file. And after the last local process closes the file, the nfs client will actually issue the delete.

If you are running a process on a nfs client and that process attempts a unlink() system call on a open file, the above scenario plays out. But the process still has the file open. You should be glad that .nfs file is still around. You must be holding the file open in order to eventually do i/o to it. If this is not the case, the process has a bug. It should close the file if the file is no longer needed. If the process is going to run for days or weeks and it is opening files that it will never close, the file table will eventually fill.

The .nfs files should not really cause any trouble unless they are very large. Some people run a cron job on the nfs server that finds .nfs files that have not been accessed in the past two weeks and deletes them.