mongodbnosql

Event scheduler (cronjob) in MongoDB?


How can I set an event scheduler in Mongodb?

I will create an event that every 4 hours calculate fields (SUM|COUNT) in the collection then save it.

What is the Best Solution to arrive at this? thanks:)


Solution

  • As of version 3.2, MongoDB has no built-in cronjob system (with the exception of the TTL index auto-delete jobs, but these won't help you to solve this problem).

    That means you will have to use an external tool to start the mongo shell with your query as a parameter to it. There are countless tools available for this. Some build into all common operating systems out-of-the box and some in form of 3rd party tools. There are far too many options to list; which is the best depends on your IT infrastructure and what your system administrators prefer.