question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cron just stops - Possible Memory Leak

See original GitHub issue

I have a Cron job that just randomly stops. I started it at around 7:30PM and by 8:10 PM it just stopped.

I was logging output to my console and it just died.

 new CronJob('*/5 * * * * *', function(){
       console.log("***************************************************");
       console.log("Cron Start: " + Date());
       var https = require('https');
       var options = {
            host: 'api.twilio.com',
            port: 443,
            path: '/2010-04-01/Accounts/' + sid + '/Queues/'+ config.twilio.queue.sid  + '/Members.json',
            method: 'GET',
            auth: sid + ":" + auth,
            agent: false
       };
       var req = https.request(options, function(rex) {
         rex.setEncoding('utf8');
         rex.on('data', function (chunk) {
           try{
                  console.log("Cron Work : " + Date());
                 obj = JSON.parse(chunk);
                 io.sockets.emit('queue', {msg:obj.total.toString()});
                 io.sockets.emit('list', obj);
                 smsModel.find({agent: null}, function(err, results){
                          io.sockets.emit('chat', results);
                  console.log("Cron Data : " + Date());
              //console.log(results);
        });

      }catch(err){
        console.log("Code 1: " + err.message);
      } 
    });
  });
  req.end();
  console.log("Cron End  : " + Date());
  console.log("***************************************************");
}, null, true, "America/Los_Angeles");

It never logged any errors from my try catch blocks.

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:14 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
StevenDStantoncommented, May 25, 2016

@semy I am actually just using two different methods.

Where it is not critical that my calls be exact to the second I am using javascripts setInterval.

It has proven to be surprising robust and accurate. Currently it runs my main loop which pushes out status updates to around 50 agents every 10 seconds.

For to the second precision I am using actual cron on my linux server. That is simple to set up with cron tab and cURL.

0reactions
semycommented, May 25, 2016

@StevenDStanton What’s your replacement of cron? Need a quick solution that works… Thanks 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Ubuntu Cron Job process not release memory automatically
But in my case, it doesn't seem memory leaking issue because the same logic or code running correctly on a test environment with...
Read more >
Cron Job Maxing Out RAM | WordPress.org
Under normal circumstances, unless you have millions or at least a few hundred thousand of cron jobs, it's unlikely to cause 503 errors...
Read more >
Memory leaking when running kubernetes cronjobs
Kubernetes will create a new cgroup each time the cronjob runs, but these are removed when the job completes (which takes a few...
Read more >
[MX] Shell script to restart a process with memory leaks by ...
[MX] Shell script to restart a process with memory leaks by using crontab. A process can at times have memory leaks and a...
Read more >
Cron: running a long php file without flaws | Linode Questions
Can php with a long timeout and cron only by them self run for 100m without ... PHP does not inherently leak memory,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found