Why use AdonisJS Scheduler?
Scheduling tasks is a common requirement in modern web applications. Whether you need to send daily reports, clean up old records, or run periodic maintenance tasks, AdonisJS Scheduler makes it simple and intuitive.Key features
Fluent API
Define schedules using an expressive, chainable API that’s easy to read and maintain
Multiple schedule types
Schedule both Ace commands and custom callback functions
Decorator support
Use the
@schedule decorator to define schedules directly on your commandsOverlap prevention
Prevent tasks from running concurrently with built-in overlap protection
Timezone support
Run tasks in specific timezones with the
.timezone() methodHot reload
Automatically restart the scheduler when files change during development
Tagging
Organize and selectively run schedules using tags
Lifecycle hooks
Execute code before and after scheduled tasks with
.before() and .after() callbacksSchedule frequency options
AdonisJS Scheduler supports a wide range of scheduling frequencies:- Seconds:
.everySecond(),.everyFiveSeconds(),.everyTenSeconds() - Minutes:
.everyMinute(),.everyFiveMinutes(),.everyThirtyMinutes() - Hours:
.hourly(),.everyTwoHours(),.everyFourHours() - Days:
.daily(),.weekdays(),.weekends() - Weeks:
.weekly(),.mondays(),.tuesdays(), etc. - Months:
.monthly(),.twiceMonthly(),.lastDayOfMonth() - Custom:
.cron('* * * * *')for custom cron expressions
Example usage
Here’s a quick preview of what scheduling tasks looks like:start/scheduler.ts
Next steps
Installation
Install and configure AdonisJS Scheduler in your project
Quickstart
Create your first scheduled task in minutes
For AdonisJS v5, use the 0.x branch of the package.