美文网首页
Shell对Mongo的两种调用方式

Shell对Mongo的两种调用方式

作者: 大数据ZRL | 来源:发表于2020-03-08 15:58 被阅读0次

将test数据库下JobLog表中数据插入JobLogBak表中

  • 方式1
local_dt=`date +%H`
if [ $local_dt -eq 0 ]; then
  mongo 172.00.00.0:27017/test --eval 'db.JobLog.find().forEach(function(d){db.JobLogBak.insert(d)})'
fi
  • 方式2
mongo 172.00.00.0:27017<<EOF
use test
var result = db.JobLog.find()
while(result.hasNext()) db.JobLogBak.insert(result.next())
EOF

相关文章

网友评论

      本文标题:Shell对Mongo的两种调用方式

      本文链接:https://www.haomeiwen.com/subject/eogddhtx.html