title: Stop Cron Job inside the scheduler Node.js
body: <p>I've created a cron-job to run a task and I want it to stop at some specific condition inside the scheduler, but it is not working.</p>
  <p>How can I stop cron job inside the scheduler?</p>
  <p>Here is my code:</p>
  <pre><code>// cron-job.js
  const cron = require('node-cron');
  
  const scheduler = cron.schedule('* * * * *', () =&gt; {
      
      let result = fetchResultAfterSomeOperation();
      if (result &lt; 20) {
          scheduler.stop();  //------------------------ It doesn't work
      }
  }, {
      scheduled: false
  });
  
  scheduler.start();
  </code></pre>