Reputation: 6481
Below cron job runs every Sunday 14:35:00, but I want to run the run job every 2 Sunday 14:35:00.
Is it possible to do that?
var CronJob = require('cron').CronJob;
new CronJob('0 35 14 * * 0', async function () {
}, null, true, 'America/Los_Angeles');
Upvotes: 5
Views: 240
Reputation: 5051
I didn't see any pattern for your requirement, but you can this
var CronJob = require('cron').CronJob;
var x = 1;
new CronJob('0 35 14 * * 0', async function () {
if (x / 2 != 1) {
x++;
//do somthing
} else {
x = 1;
}
}, null, true, 'America/Los_Angeles');
Upvotes: 2