Cron

Introduced in 4.0.0

Stability: 2 - Stable

const Cron = require('kado/lib/Cron')

This library will introduce scheduled Cron support that mimics the UNIX cron support commonly found in operating systems.

There is a nice enhancement with this library that will increase the resolution of the execution to second level. This is done by taking 6 arguments instead of

  1. When 5 arguments are provided like traditional Cron the system will substitute 0 for the first argument to mimic UNIX cron behavior.

Class: CronJob

CronJob.constructor(options)

Available options

CronJob.setName(name)

CronJob.setSchedule(schedule)

CronJob.addHandler(fn)

CronJob.getHandler(name)

CronJob.removeHandler(name)

CronJob.isExecutableSecond(sec, against)

Note: Always returns true when set to *

CronJob.isExecutableMinute(min, against)

Note: Always returns true when set to *

CronJob.isExecutableHour(hour, against)

Note: Always returns true when set to *

CronJob.isExecutableMonthDay(monthDay, against)

Note: Always returns true when set to *

CronJob.isExecutableMonth(month, against)

Note: Always returns true when set to *

CronJob.isExecutableWeekDay(weekDay, against)

Note: Always returns true when set to *

CronJob.isExecutable(against)

Confirm the job is safe for execution based on currency and schedule.

CronJob.testSchedule(againstDate)

CronJob.executeHandler(handlerKeys, handlers, now)

CronJob.execute(now)

Class: Cron

static Cron.getInstance()

static Cron.newJob(options)

Cron.constructor()

Cron.add(name, cronJob)

Cron.remove(name)

Cron.removeAll()

Cron.get(name)

Cron.count()

Cron.all()

Cron.handleInterval()

Cron.start()

Cron.stop()