Reputation: 432
i tried this package cron.
const CronJob = require('cron').CronJob;
console.log('Before job instantiation');
const job = new CronJob('0 0 10-12,18-23 * * 0-6', function() {
upload //
});
console.log('After job instantiation');
job.start();
i need to upload all days in a week, in between 10-12 am and 6-11pm. so i need to start upload at 10 am and pause it in 12am. and again resume my upload at 6pm and pause at 11pm.
but this cron fires every one hour between 10-12 am and 6-10pm, but i need to sense only at 10 , 12 , 6 , 10 not in between hours.
how to do this ?
Upvotes: 1
Views: 61
Reputation: 451
Your pattern for hours specifies two ranges "10-12,18-23", so it is doing what you told it to.
If you want to accomplish your goal, you should use "10,12,18,22' instead. Unless your goal really intended for 11 as the last hour then you should use 23 instead of 22.
Upvotes: 1