Scenario:
We are using an NFS share to allow clients to upload raw video material. The files are then polled from the directory on the (NFS) server in order to be processed. Since we do not want to process files which have not finished uploading yet, I want to determine in the server-side script (Bash), if the file is still in use.
As the man pages say, both fuser
and lsof -N
shall allow for detecting in-use files on NFS shares. However, I do not "see" the files as in use on the server which results in corrupt files later in the processing.
Setup:
My NFS /etc/exports
contains these settings (UID and GID being the owner of the shared directory on the server, line wrapped for better display):
/export/foo 10.3.2.0/255.255.255.0
(rw,sync,no_subtree_check,all_squash,anonuid=1001,anongid=1001)
The client mounts this share using:
10.3.2.197:/export/foo /data002/ nfs defaults 0 0
The server is a Ubuntu 10.04 using "nfs-kernel-server 1:1.2.0-4ubuntu4", the client is an SLES 10 SP2
When I open a file on the client (inside the shared directory), using
echo "Hello" > test.txt && tail -f foo.txt
and then check (still on the client) if the file is in use
fuser foo.txt
I can see that the file is in use. However, when checking on the server side (both fuser foo.txt
and lsof -N | grep foo.txt
) I do not get any usage information.
How can I check on the server if a file on the NFS share is currently in use (regardless if locally or remote)? Or what am I doing wrong in my current setup?