Questions tagged [agenda]

Agenda is a light-weight job scheduling library for Node.js, with a Mongo persistence layer.

Agenda is a light-weight job scheduling library for Node.js.

It offers:

  • Minimal overhead. Agenda aims to keep its code base small.
  • Mongo backed persistance layer.
  • Promises based API
  • Scheduling with configurable priority, concurrency, and repeating
  • Scheduling via cron or human readable syntax.
  • Event backed job queue that you can hook into.
  • Optional standalone web-interfaces (see agendash and agenda-ui)

Installation

Install via NPM

npm install agenda

You will also need a working mongo database (2.6+) to point it to.

Example Usage

var mongoConnectionString = "mongodb://127.0.0.1/agenda";

var agenda = new Agenda({db: {address: mongoConnectionString}});

// or override the default collection name:
// var agenda = new Agenda({db: {address: mongoConnectionString, collection: "jobCollectionName"}});

// or pass additional connection options:
// var agenda = new Agenda({db: {address: mongoConnectionString, collection: "jobCollectionName", options: {server:{auto_reconnect:true}}}});

// or pass in an existing mongodb-native MongoClient instance
// var agenda = new Agenda({mongo: myMongoClient});

agenda.define('delete old users', function(job, done) {
  User.remove({lastLogIn: { $lt: twoDaysAgo }}, done);
});

agenda.on('ready', function() {
  agenda.every('3 minutes', 'delete old users');

  // Alternatively, you could also do:
  agenda.every('*/3 * * * *', 'delete old users');

  agenda.start();
});

More Info:

https://github.com/agenda/agenda

98 questions
0
votes
1 answer

How to get job status in Node.js Agenda?

agendash is an extension of Agenda. This package can list which schedules are currently running. There is a status field, because I want to make another panel, how do I get this status through the Agenda?
Finn
  • 1,323
  • 5
  • 24
  • 46
0
votes
1 answer

agenda scheduling defaulting nextRunAt to next year

I am trying to schedule jobs usign the agenda library. I've done this: await this.agenda.start() this.agenda.define(scheduler.id, { lockLifetime: 10000 }, (job, done) => { console.log('Hello world!') //some logic using values on job…
Vitor Ceolin
  • 196
  • 17
0
votes
1 answer

Agenda when instantiated with existing Mongodb connection, not running the job definition

Instead of using the mongodb connection string when initialising the agenda instance, i am using an already connected mongo client instance. The issue i am facing is that a document for the agenda.every gets added to the collection, but when the…
0
votes
1 answer

Agenda scheduler not running

I am trying to schedule a one-time job on a specific date, however, the callback never gets called once the date is reached. The job gets created and added to the collection. Not sure what I am doing wrong. Using agenda const agenda = new Agenda({ …
joethemow
  • 1,641
  • 4
  • 24
  • 39
0
votes
0 answers

Delete document in mongodb collection with deleteOne where data is an object with the id

Im trying to delete a record in my mongodb collection that look like this { "name": "do sftp backup", "data": { "scheduleId": 95 }, "priority": 0, "type": "normal", "nextRunAt": null, "lastModifiedBy": null, …
Erraco
  • 138
  • 1
  • 12
0
votes
1 answer

how can I convert react-native data?

// i have to change my data to this form items={{ '2021-04-20': [{name: 'item 1 - any js object'}], '2012-04-21': [{name: 'item 2 - any js object'}] }} I am trying to show data below using react-native calendar library's agenda. And agenda needs…
0
votes
1 answer

Connecting to MongoDB - Command 'createIndexes' requires authentication (Maybe Agenda.js related?)

As I'm introducing authentication for my MongoDB instance in Docker, I ran into problems which are probably related to the way agenda.js tries to connect to MongoDB, as the connection string invokes successful logs for mongoose connecting to the DB,…
GoWithTheFlow
  • 252
  • 6
  • 16
0
votes
1 answer

ReactNative Agenda not rendering any items

I am using the Agenda from wix/react-native-calendars in my code. The problem is its not showing any items the way its intended to show on the screen. I don't know where I am going wrong. I have been trying to figure out the solution but nothing…
0
votes
0 answers

How to allow website visitors to directly subscribe to ics calendar file?

For my first website project I am making a .ics file filter. I've managed to filter the .ics files according to the user's input and was able to host the .ics files on my website. The .ics files are accessible through a link, e.g.…
0
votes
0 answers

Cannot replace expired jobs after server restart

I am trying to re-create all the expired job at the server start. (async function() { await agenda.start(); const jobs = await agenda.jobs({nextRunAt: {$lt: new Date(Date.now())}}); for(var job of jobs){ var { _id, name, data, type,…
John doe
  • 3,680
  • 7
  • 31
  • 65
0
votes
1 answer

How do I block-out daily timeblocks in Org agenda

Hello I would like to create a time block that will be added to my agenda every day. * Walk dog SCHEDULED: <2020-06-29 Mon 13:30-14:00 +1d> I know this is possible with a Repeated task. But than I have to mark that task daily as DONE I want to…
0
votes
1 answer

Using Agenda for job schedule not running

I am using Agenda to schedule my job at a certain time. The job will contain a certain array of emails that will be sent automated emails in the interval of 10 seconds, but the issue is the job is not executing as expected. The scheduler runs…
program_bumble_bee
  • 439
  • 2
  • 25
  • 57
0
votes
1 answer

How to use node cluster mode with agenda cronjobs

I am currently using nodejs and agenda to run cronjobs. Currently, there are 10 cronjobs and since node is single threaded it's taking a longer time for each of them to be done when all of them run simultaneously. I have tried pm2 by running the…
0
votes
1 answer

how can i pass a date formate in agenda jobs

const mongoconection =url; const agenda = new Agenda({ db: { address: mongoconection, collection: "agendajobs", option: { useUnifiedTopology: true } } }); new Promise(resolve=> agenda.once('ready', resolve)); agenda.define("say…
0
votes
1 answer

Agenda job library, How to execute cron every last day of the month at mid night or last minute of the day

Agenda job library, please help me to run cron on every last day of the month at 23:50. const cron = job.create('sendInvoice', { msg: 'Hello world', }); await cron.repeatEvery('0 0 * * * *').repeatEvery('1 month').save(); //Executive daily
Naisarg Parmar
  • 759
  • 8
  • 25