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

 

重定向输入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

 

 

 

 

 

 

 

 

 

 

 

 

 

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

相关文章:

  • 2021-08-23
  • 2021-08-10
  • 2021-09-07
  • 2022-12-23
  • 2021-11-30
  • 2021-12-30
  • 2021-11-13
猜你喜欢
  • 2021-11-24
  • 2021-12-31
  • 2021-06-21
  • 2021-06-02
  • 2022-02-16
  • 2022-12-23
相关资源
相似解决方案