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