I use df -kh to get the file system usage, but the trouble is if there is any NFS mount failure in any of the boxes the command will hang.

Is there a better way to monitor file systems other than df , or is it possible to mention a timeout to df command ?

  • Aren't -k and -h contradictory? – Random832 Mar 12 '15 at 16:07

I found the answer here

The trick is to use the command timeout

So the ideal way is timeout 2 df -kh , here 2 is the timeout in seconds.

  • I believe that for some older kernels unless the filesystem is mounted with the "intr" flag, then all NFS operations are uninterruptible. I'm not sure what "timeout" does in this case, but I suspect that it abandons the "df" command so you may end up with a bunch of zombie df's in the background. – Johnny Mar 12 '15 at 17:48
  • I set the timeout to get the output of df in 2 seconds. If it is taking more than 2secs there is a trouble in some of the file systems. – Govind Kailas Mar 12 '15 at 17:53
  • I see in general it returns the results in milli seconds. – Govind Kailas Mar 12 '15 at 17:56


df -khl

instead. Option -l tells df to report on local file systems only (from man df):

-l, --local
    limit listing to local file systems

(the man df command prints the complete manual page for df.)

  • I wanted to monitor NFS mounts as well. The trouble is, if there is an issue with the NFS mount the df command will go in a hung state. – Govind Kailas Mar 12 '15 at 9:39
  • 2
    1) nfs drive sould be monitored by their server. 2) however there is no switch to df that could timeout, or predict a possible hang. 3) depending on your context, you might wish to use automount or soft NFSmount. – Archemar Mar 12 '15 at 9:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.