JSPM

  • Created
  • Published
  • Downloads 2484
  • Score
    100M100P100Q121024F
  • License MIT

Task scheduler for AdonisJS

Package Exports

  • adonisjs-scheduler
  • adonisjs-scheduler/build/providers/SchedulerProvider.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (adonisjs-scheduler) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

AdonisJS Scheduler (WIP)

Task scheduler for AdonisJS

npm License: MIT Typescript

Scheduler code example

Getting Started

This package is available in the npm registry.

npm install adonisjs-scheduler

Next, configure the package by running the following command.

node ace configure adonisjs-scheduler

Running The Scheduler

node ace scheduler:run
# or
node ace scheduler:work

Defining Schedules

// start/scheduler.ts

import Scheduler from "@ioc:Adonis/Addons/Scheduler"

import PurgeUsers from "Commands/PurgeUsers";

Scheduler.command("inspire").everyFiveSeconds();
Scheduler.command(PurgeUsers, [ "30 days"]).everyFiveSeconds();

Scheduler.call(() => {
    console.log("Pruge DB!");
}).weekly();

Schedule Frequency Options

Method Description
.cron('* * * * *'); Run the task on a custom cron schedule
.everyMinute(); Run the task every minute
.everyTwoMinutes(); Run the task every two minutes
.everyThreeMinutes(); Run the task every three minutes
.everyFourMinutes(); Run the task every four minutes
.everyFiveMinutes(); Run the task every five minutes
.everyTenMinutes(); Run the task every ten minutes
.everyFifteenMinutes(); Run the task every fifteen minutes
.everyThirtyMinutes(); Run the task every thirty minutes
.hourly(); Run the task every hour
.everyTwoHours(); Run the task every two hours
.everyThreeHours(); Run the task every three hours
.everyFourHours(); Run the task every four hours
.everyFiveHours(); Run the task every five hours
.everySixHours(); Run the task every six hours
.daily(); Run the task every day at midnight
.weekly(); Run the task every Sunday at 00:00
.monthly(); Run the task on the first day of every month at 00:00
.quarterly(); Run the task on the first day of every quarter at 00:00
.yearly(); Run the task on the first day of every year at 00:00