检测磁盘挂载的方法

1、脚本

#!/bin/bash
/bin/df -h > /tmp/df.txt
if cat /tmp/df.txt | grep /usr/local/tomcat7/webapps/dsideal_yy/ >/dev/null
then
  echo "磁盘挂载正常!"
else
  echo "磁盘挂载异常,正在重新挂载!"
  #umount -l /usr/local/tomcat7/webapps/dsideal_yy/html/down
  #echo ''>>/root/.ssh/known_hosts
  #echo "dsideal"|sshfs -C -o nonempty,allow_other,sshfs_sync,reconnect,password_stdin root@10.10.14.240:/ /usr/local/tomcat7/webapps/dsideal_yy/html/down
 mount -t cifs -o sync,noatime,username='Administrator',password='DsideaL4r5t6y7u' //10.10.6.216/down /usr/local/tomcat7/webapps/dsideal_yy/html/down
echo "恭喜,挂载已成功完成!"
fi

 2、定时执行

vi /etc/crontab

* * * * * root  /usr/local/checkdisk.sh > /dev/null 2>&1

 

posted @ 2017-10-10 13:21  糖豆爸爸  阅读(690)  评论(0编辑  收藏  举报
Live2D