Skip to content

Instantly share code, notes, and snippets.

@William-Yeh
Created April 16, 2014 04:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save William-Yeh/10807315 to your computer and use it in GitHub Desktop.
Save William-Yeh/10807315 to your computer and use it in GitHub Desktop.
Simple tool to db.fsyncLock() on MongoDB.
#!/bin/bash
MONGODB_NAME=$1
MONGODB_PASS=$2
MONGODB_HOST=$3
MONGODB_PORT=${4:-27017}
if [ $# -lt 3 ]; then
echo "Simple tool to db.fsyncLock() on MongoDB."
echo "Usage: lock-mongodb.sh username password host [port]"
exit 1
fi
echo -e "use admin\ndb.auth('$MONGODB_NAME','$MONGODB_PASS')\ndb.fsyncLock()\n" | mongo --norc --host $MONGODB_HOST --port $MONGODB_PORT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment