I've been pondering about an efficient way to locate stale NFS files for a few days with out much success and was wondering if there are better approaches to the problem.


every once in a while I'm unable to load my server URL due to stale NFS (diagnosed after the fact). Stale files are usually found using ls -ltR /<mounted directory path> | grep "\?", but this usually takes some time (since it goes over all files in a given path).

To further clarify, the issue seen in specific files such as Java library file(s) rather than the whole mount.

Hence, my question in short, is there more efficient way than ls -ltR | grep "\?" to locate stale NFS files?

Thank you.


To clarify, fixing the issue isn't intended to be in the scope of this question, since I've written a script to handle stale NFS situation (with unmount/mount, lsof, kill -15).

  • Are you talking about individual NFS file handles going stale, or the mounts themselves?
    – Sobrique
    Commented Sep 20, 2014 at 21:41
  • @Sobrique, certain files (such as in Java lib) go stale which prevents the server from working correctly.
    – Simply_Me
    Commented Sep 20, 2014 at 21:43
  • OK, so what that means is - something's modified the file - either by moving it/renaming it/editing it - and something on your client is therefore out of sync. The real answer is to figure out what's doing that - NFS file handles 'going stale' is expected behaviour, to avoid data corruption.
    – Sobrique
    Commented Sep 20, 2014 at 21:47
  • 1
    mount -o remount will refresh the NFS handles on the mount. Doesn't 'detect' them per se, but will clear the problem.
    – Sobrique
    Commented Sep 20, 2014 at 21:49
  • 1
    @Sobrique , to clarify, I'm aware on how to fix the issue and have written bash script for it. My question scope is mainly to reduce diagnostic time.
    – Simply_Me
    Commented Sep 20, 2014 at 21:51

1 Answer 1


The real answer to fixing stale NFS file handles is doing mount -o remount. But ideally, instead you'll track down what's making the changes to the file system, as that's what's causing this in the first place.

  • fixing it is not in the scope of the question, since I've scripts to do that. I'd just like to save time in finding out if it's a stale NFS file issue or not.
    – Simply_Me
    Commented Sep 20, 2014 at 21:50
  • 3
    In which case - no, I don't think there's a faster way, as you need to stat the file to detect the problem - your ls does that already. find might be slightly faster, but it's fundamentally got to do the same thing.
    – Sobrique
    Commented Sep 20, 2014 at 21:53
  • Thank you for the information, I was afraid that'll be the answer.... :-(
    – Simply_Me
    Commented Sep 20, 2014 at 21:55
  • 1
    The open syscall should be returning a different error code to normal - ESTALE. You might be able to catch that happening, either within the app - or maybe by turning on auditing.
    – Sobrique
    Commented Sep 20, 2014 at 22:01
  • wouldn't this require exact file name? I'm not familiar with open syscall (just from what I've read after you posted your comment).
    – Simply_Me
    Commented Sep 20, 2014 at 22:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .