0

I'm using node-schedule and its not working with the cron expression strings. What am I doing wrong here?

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

schedule.scheduleJob('*/5 * * * * * *', function(){
    console.log(Date.now());
});

This just executes once, when the server starts.

I dont want to create RecurrenceRule (which worked), instead, just use these strings to create jobs.

Should I just try node-cron?

Dushyant Bangal
  • 6,048
  • 8
  • 48
  • 80

2 Answers2

0

Directly from the node-schedule docs:

if you only want to do something like "run this function every 5 minutes", you'll find setInterval much easier to use, and far more appropriate.

It sounds like you are trying to do something it is specifically designed not to do. Perhaps just use setInterval?

duncanhall
  • 11,035
  • 5
  • 54
  • 86
  • No, the pattern I posted was just a basic example. I need a task scheduler, there will be other factors too, not just number of milliseconds. – Dushyant Bangal Feb 03 '16 at 05:09
0

node-schedule doesn't fully support string patterns and they are trying to resolve that issue. You may go ahead with node-cron and this might help you.

Community
  • 1
  • 1
kumar
  • 481
  • 3
  • 7
  • 18