Scheduler Hangs with 100% CPU usage (possible DST Issue?) #11

iammer opened this Issue Mar 10, 2013 · 5 comments


None yet

4 participants

iammer commented Mar 10, 2013

I have a scheduled job that runs everyday at 9:45pm. Everything was working fine until today, when the node process hung with 100% CPU usage. The next time this is scheduled to run is after a daylight savings time change, and I speculate that is causing the issue. See code below to reproduce. I see "Scheduling job.", then my CPU goes to 100% and I never see "Scheduling done."

I was previously using version 0.1.5 and I after I noticed the issue I switched to 0.1.7, but that did not resolve it.

Note: This may only fail the day before a daylight saving time change.

var schedule=require('node-schedule');

console.log('Scheduling job.');

schedule.scheduleJob({hour: 21, minute: 45},function() {
    console.log('Job ran');

console.log('Scheduling done.');
mattpat commented Mar 10, 2013

That's exactly what it is. The scheduler increments the date until it finds a matching occurrence. That requires incrementing through, in this case, 2am on March 10th, which is a time that does not exist. I'll take a look at this.

mattpat commented Mar 10, 2013

Give it a shot!

@mattpat mattpat closed this Mar 10, 2013
iammer commented Mar 10, 2013

Yep, just pulled down 0.1.8. Working now, thanks. Wow, that was quick!

abv commented Mar 11, 2014

I ran into this same issue this past weekend. On Sunday 3/8/2014 I woke up to our CPU at 100% and code not running. After commenting out the following code, everything continued to work. We are using version 0.1.13.

schedule.scheduleJob({ hour: 2, minute: 10 }, function(){
@macalinao macalinao added a commit to macalinao/node-schedule that referenced this issue Jan 3, 2015
@macalinao macalinao Tweaked date math behavior for DST boundaries, should address issue #11 2e3a9d3
valayDave commented Oct 4, 2016 edited

This is happening to me right now

var Jobs = appRequire('jobs');

var Scheduler = require('node-schedule');

var hourlyRule = new Scheduler.RecurrenceRule();
hourlyRule.minute = 60

Scheduler.scheduleJob(hourlyRule, function () {
    var inputObject = {startDate : new Date().setHours(0,0,0,0),endDate : new Date().setHours(23,59,59,999)}// specify time period here.
    Jobs.dailyCron(inputObject, function (err) {

I have such a rule but once the process starts the CPU spikes to a 100% and all other processes on that machine Die.

I am using Version 1.1.1

What should I Do?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment