Reputation: 17
I'm using Node-Schedule package and I'm having some trouble to define the criteria using the * system. Does anyone know how can I run this task every day 15 and 30 of a month (15 days interval)
var schedule = require('node-schedule');
var tarefa = schedule.scheduleJob('15-30 * * ', function() {
console.log("TAREFA");
});
One more question, let's say I wanna change this later based on user selected option, how can I get this current task schedule and change this interval later?
Thanks in advance!
Upvotes: 0
Views: 4789
Reputation: 586
0 0 0 1,15 * ?
should work (see Quartz Cron expression :Run every 15 days ie twice in a month).
To change the schedule, you can call the rescheduleJob
method with the job's name and the new user-specified schedule.
var schedule = require('node-schedule')
schedule.scheduleJob('myJob', '0 0 0 1,15 ? *', function() { console.log('hi') } )
schedule.rescheduleJob('myJob', '0 0 0 1,20 ? *')
Upvotes: 2