The interval at which the job should run. Can be a cron expression, human-readable string, or milliseconds.
Configuration options for the job
Method decorator
are automatically scheduled when registered with the Agenda instance. They will run at the specified interval.
import { JobsController, Every, Job } from 'agenda';
@JobsController({ namespace: 'maintenance' })
class MaintenanceJobs {
// Run every 5 minutes
@Every('5 minutes')
async healthCheck(job: Job) {
await this.checkSystemHealth();
}
// Run daily at midnight using cron
@Every('0 0 * * *', {
name: 'dailyCleanup',
timezone: 'America/New_York'
})
async cleanupOldData(job: Job) {
await this.deleteOldRecords();
}
// Run every hour with high priority
@Every('1 hour', { priority: 'high', concurrency: 1 })
async generateReport(job: Job) {
await this.createHourlyReport();
}
}
Method decorator that defines a recurring job.
Jobs decorated with