5

I know this might sound a bit dumb, but can I use node-cron to create two crone-jobs to run on two days of the week which are non-consecutives? Do I need to call two CronJob functions, or is there a way to use only one?

Corrado
  • 645
  • 1
  • 6
  • 16

1 Answers1

6

Node-cron uses the same rules as crontab, so you can set a rule like this:

cron.schedule('30 3 * * sun,tue', function(){
  console.log('running a task at 3:30 on Sunday and Tuesday');
});

Note that this is only if you want to run the same job on both days. If you wan to run different jobs you have to create different tasks.

Larry Turtis
  • 1,907
  • 13
  • 26
  • Node-corn absolutely uses the corntab rules, to achieve your desired rule follow the easy link below and create your job. https://crontab.guru/#30_3_*_*_sun,sat – Kishore Chandra Nov 02 '16 at 19:07