Created
January 30, 2017 16:50
-
-
Save solocommand/1c82374bd0d41e96795572e98bdb74b0 to your computer and use it in GitHub Desktop.
Continually execute mongo JS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
function error { | |
echo -e "\033[91mAn error was encountered! $1\033[0m" | |
exit 1 | |
} | |
if [ "$#" -ne 2 ]; then | |
error "Usage: mongoupdate DATABASE SCRIPT" | |
fi | |
MONGO_HOST="localhost" | |
DATABASE=$1 | |
SCRIPT=$2 | |
if [ ! -e $SCRIPT ]; then | |
error "File $SCRIPT does not exist!" | |
fi | |
echo -e "\033[32mExecuting $SCRIPT on $DATABASE\033[0m" | |
COMMAND="mongo $MONGO_HOST/$DATABASE $SCRIPT" | |
watch -n0.5 $COMMAND |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment