script in bash to store the result of a Mongodb query

1

I hope that someone can help me.

I need to create a bash script that connects to a Mongodb:

mongo --host mongodb://IP:PORT,IP:PORT/admin?replicaSet=rs0 -u admin -p passadmin

select the db:

use Data

and launch the query:

db.OPERATIONS.find({"Description":"OK."}).count() 

of the last hour, I think it would be something like this:

{$lte: new Date().getTime()-(1*60)} 

and save it in a file eg:

/tmp/count.log con el timestamp de la consulta.

Thank you very much in advance. Greetings.

    
asked by Kleiner zin 11.10.2018 в 14:27
source

0 answers