corradoCane corradoCane - 2 months ago 21
Javascript Question

Node-cron jobs running on fixed week-days

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?


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.