最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Node-cron jobs running on fixed week-days - Stack Overflow

programmeradmin1浏览0评论

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?

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?

Share Improve this question asked Nov 2, 2016 at 18:23 CorradoCorrado 6651 gold badge8 silver badges17 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 7

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.

发布评论

评论列表(0)

  1. 暂无评论