17.shell检测NFS挂载

read -t1 < <(stat -t "/my/mountpoint")
if [ $? -eq 1 ]; then
   echo NFS mount stale. Removing... 
   umount -f -l /my/mountpoint
fi


或

mountpoint="/my/mountpoint"
read -t1 < <(stat -t "$mountpoint" 2>&-)
if [[ -n "$REPLY" ]]; then
  echo "NFS mount stale. Removing..."
  umount -f -l "$mountpoint"
fi


#### 2>&- 子shell的输出用2>& – 静音
 

 

posted @ 2021-04-06 08:48  天涯160  阅读(437)  评论(0)    收藏  举报