I have a procedure I want to initiate only if several tests complete successfully.
One test I need is that all of my NFS mounts are alive and well.
Can I do better than the brute force approach:
mount | sed -n "s/^.* on \(.*\) type nfs .*$/\1/p" |
while read mount_point ; do
timeout 10 ls $mount_point >& /dev/null || echo "stale $mount_point" ;
done
Here timeout
is a utility that will run the command in the background, and will kill it after a given time, if no SIGCHLD
was caught prior to the time limit, returning success/fail in the obvious way.
In English: Parse the output of mount
, check (bounded by a timeout) every NFS mount point. Optionally (not in the code above) breaking on the first stale mount.