直接上脚本:
#!/bin/bash #autor: firxiao #date: 20150909 #usage: check mount ##config mountpoint="/nfs" type1="nfs" ### function check { /usr/bin/stat -f $mountpoint | grep -o ‘Type: [a-zA-Z1-9 \t]\+$‘ | grep -o ‘: [a-zA-Z0-9 \t]\+$‘ | grep -o ‘[a-zA-Z0-9]\+‘ } function remount { /bin/mount -a } type2=`check` if [ $type1 = "$type2" ] then echo "$mountpoint is already mounted" else echo "$mountpoint is not mount , will remount now" remount fi
需要配置下脚本
挂载点 和 目录类型
脚本中的挂载点为 /nfs 类型为nfs
脚本中的remount 你也可以根据你的情况来填写
可以使用
stat -f 路径
来查看type 然后填到脚本中即可
加到计划任务即可定时检查挂载
希望这个脚本提供给你思路,不单单可以检查nfs哦
原文:http://my.oschina.net/firxiao/blog/503655