- #!/bin/bash
- port="27017"
- start="nohup /usr/bin/mongod --config /etc/mongod.conf & "
- EMAIL="/bin/echo mongodb | mutt -s "重新启动mongodb"
- netstat -ln |awk '/^tcp/{print $4}'|grep -q ":$port$"|| {
- #restart mongodb
- eval $start;
- exit $?
- }
- exit 0
之前的 mongo 从库没有 nohup 启动,从有时候会自动挂掉,写这个脚本是为了,过一段时间让他自动起来 ··
来源: http://www.bubuko.com/infodetail-1989531.html