Cron task for mongodb command

Viewed 15

I was wondering how can I create a cron task that can run a command on a mongoshell connection.

Basically I would like to be able to connect to the mongoshell once a month an run a specific command.

The version of mongodb that I'm running is MongoDB shell version: 2.0.7

Thanks

1 Answers

You can create a simple cronjob like this:

0 0 1 * * /usr/bin/mongosh "mongodb://user:pass@localhost/?authSource=admin" --quiet --eval "... your command"
Related