Shell对Mongo的两种调用方式

2020-03-08  本文已影响0人  大数据ZRL

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

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
mongo 172.00.00.0:27017<<EOF
use test
var result = db.JobLog.find()
while(result.hasNext()) db.JobLogBak.insert(result.next())
EOF
上一篇 下一篇

猜你喜欢

热点阅读