title: Dynamically update nodejs cronjob period
body: <p>I need to do some task periodically in my nodejs app. If it was fixed period then it is working fine. But in my case the period should change dynamically. below is my code which was not working as I expected. here cronjob is not updating it's period when I changed the period.</p>
  
  <pre><code>var period = 1;
  var CronJob = require('cron').CronJob;
  new CronJob('*/' + period + ' * * * * *', function () {
      console.log("some task");
  }, null, true, "Indian/Mauritius");
  
  
  new CronJob('*/5 * * * * *', function () {
      period = period * 2;
      console.log("updating cronjob period");
  }, null, true, "Indian/Mauritius");
  </code></pre>