<span>mongodb的shell脚本</span>

#################

 

重定向输入mongo脚本:

#! /bin/bash
 
mongo --username root  --password 123456 --host 10.10.10.10 --port 27017 --authenticationDatabase admin <<EOF
use apple;
db.currentOp();
EOF

 

转义$:

shell中使用mongodb的时候,如果需要查询条件$,则需要转义$,因为$字符在shell中是变量的意思:

 

#! /bin/bash
 
mongo --username root  --password 123456 --host 10.10.10.10 --port 27017 --authenticationDatabase admin <<EOF
use apple;
print("该实例上的连接数情况:db.serverStatus().connections;");
db.serverStatus().connections;
print("===========================");
db.currentOp({ "desc" :{\$nin: ["rsSync-0","ReplBatcher","monitoring keys for HMAC","WT OplogTruncaterThread: local.oplog.rs","NoopWriter"]}});
EOF

 

 

 

 

 

 

 

 

 

 

 

 

 

###################

全部评论

相关推荐

点赞 评论 收藏
分享
04-08 16:35
门头沟学院 Java
站队站对牛:实在是恶心的公司
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务