简体   繁体   中英

node-schedule Run every first monday of the month

Can anyone please confirm that this is the right node-schedule rule that runs the code every first Monday of the month at 02:59AM.

var epr_update_rule = new schedule.RecurrenceRule();
epr_update_rule.dayOfMonth = [1, 2, 3, 4, 5, 6, 7];
epr_update_rule.dayOfWeek = 1;
epr_update_rule.hour = 2;
epr_update_rule.minute = 59;

My idea is that it will try to run it on the first 7 days of the month but it will only succeed on a Monday and will therefore be run only ONCE in the first 7 days of the month, ie on Monday.

Can anyone please confirm?

Thanks!

You can use Object-literal syntax, which is more easy and simple to undersdtand,

var job = schedule.scheduleJob({hour: 02, minute: 59, dayOfWeek: 1, dayOfMonth: [1,2,3,4,5,6,7]}, function(){
  console.log('Your scheduleJob!');
});

Here is the documentation for the same

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM