Will running Node.js scripts as CRON jobs without closing database connection eventually kill all the RAM?
<p>I am building Node.js scripts that will be ran as CRON jobs. (full terminal scripts). These scripts fetch data from all around using APIs and MongoDB (native driver) is used. I don't didn't use <code>db.close()</code> statement and because of that script will never end by itself (or at least it looks like that way from the terminal), to finish it, it is necessary to press CTRL+C to cancel. </p>

<p>Back then when I was writing these scripts, someone from Stack overflow told me that it is not required to close connection anyway. So I let it be. </p>

<p>Now I wonder, do these scripts actually are still running? And as these would be ran as CRON jobs, with small intervals, does that mean that these scripts will eventually kill RAM from the server? Does that mean, there will be thousands scripts running and waiting for <code>db.close()</code> statement?</p>

<p>Example code:</p>

<pre><code>MongoClient.connect(mongoUrl, (err, db) =&gt; {
  if (err) {
    console.log(err);
    return;
  }

  var usersCollection = db.collection('users').find();

  usersCollection.on('data', (doc) =&gt; {

    console.log(doc);

  });
</code></pre>