title: Cron jobs do not run in Heroku
body: <p>I am developing a Nodejs server which I am uploading to Heroku. The file has a Cron job which is meant to run every 4th hour. But when I check in nothing happens. I am using the free version of Heroku and I do not appear to be exceeding my limit of free Dyno hours.</p>
  <p>The code in my Index.js file looks like below. As you can see in this simple example, I just want the application to log the time every 4th hour. I also update a variable which should indicate the latest update, which can be used to check for status of updates.</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>import express from 'express';
  const app = express();
  import cors from 'cors';
  app.use(cors());
  import cron from 'node-cron';
  import dotenv from 'dotenv'
  dotenv.config()
  const port = process.env.PORT || 3050;
  
  var lasttime = '';
  var task = cron.schedule("0 0 */4 * * *",() =&gt; {
          console.log("date: "+Date());
          lasttime = Date();
      }, {
          scheduled: true
      }
   );
  
  app.get('/api_x', async (request, response) =&gt; {
  reply=lasttime;
  response.json({reply:reply});
  });</code></pre>
  </div>
  </div>
  </p>
  <p>This works fine when I run it on my local computer. When I run it on Heroku it logs the message once, doesn't update the variable lasttime and then does nothing.
  When I check the logs for the App on Heroku it reads:</p>
  <p><code>Unidling</code>
  <code>State changed from down to starting</code>
  <code>Starting process with command npm start</code>
  <code>webdesign@1.0.0 start /app</code>
  <code>node index.js</code>
  <code>listening at 10006</code>
  <code>State changed from starting to up</code></p>
  <p>What could be causing my Cron job not to run?
  (I have also tried using setInterval, but still no results.)</p>