Reputation: 100
I want to schedule job at a particular time using agenda node js
var agenda = new Agenda();
agenda.define('initA', function(job) {
console.log("INITA AGENDA");
job.repeatAt('at 13:25');
job.save();
});
agenda.on('ready', function() {
console.log("Agenda ready to start");
agenda.start();
});
Upvotes: 0
Views: 1199
Reputation: 221
first you must Create a job Processor - which define its processing behavior.
agenda.define('initA', function(job) {
console.log("INITA AGENDA");
job.repeatAt('at 13:25');
job.save();
});
Then use either 1. or 2.
1. agenda.Create(jobName, data)const job = agenda.create('initA', { id: 1 });
job.schedule('tomorrow at 6pm');
await job.save();
2. agenda.schedule(when, name, [data])
as shown below
agenda.schedule('tomorrow at noon', 'initA', { id: 1 });
Upvotes: 0