Cron just stops - Possible Memory Leak
See original GitHub issueI 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:
- Created 9 years ago
- Comments:14 (4 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@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.
@StevenDStanton What’s your replacement of cron? Need a quick solution that works… Thanks 😃