Execute mongo commands through shell script to deal with cache problems

Processing cache commands in mongo db.runCommand({closeAllDatabases:1})

 

1. Single command

@echo on

f:

cd \ mongo \ bin

echo db.runCommand({closeAllDatabases:1})| hly 127.0.0.1:27017/admin 

pause

 

2. Multiple commands (tried it, and it died directly without effect)

mongo admin -u$user -p$pw <<EOF
Order
Order
EOF
$user user
$pw password
If user authentication is not set, then the following -u and -p do not need to be added.
echo plus pipe character to pass the command into mongo's command line
echo "db.serverStatus().mem" | mongo admin -u$user -p$pw

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326013914&siteId=291194637