Croner

Usage (JavaScript)

Configuration #


KeyDefault valueData typeRemarks
nameundefinedStringIf you specify a name for the job, Croner will keep a reference to the job in the exported array scheduledJobs. The reference will be removed on .stop().
maxRunsInfiniteNumber
catchfalseBoolean|FunctionCatch unhandled errors in triggered function. Passing true will silently ignore errors. Passing a callback function will trigger this callback on error.
timezoneundefinedStringTimezone in Europe/Stockholm format
startAtundefinedString|DateDate, or ISO 8601 formatted datetime (2021-10-17T23:43:00)
in local time (according to the timezone or utcOffset option if passed). Inclusive, a run exactly at startAt is included (except when interval is set)
stopAtundefinedString|DateDate, or ISO 8601 formatted datetime (2021-10-17T23:43:00)
in local time (according to the timezone or utcOffset option if passed). Exclusive, a run exactly at stopAt is not included
interval0NumberMinimum number of seconds between triggers.
pausedfalseBooleanIf the job should be paused from start.
contextundefinedAnyPassed as the second parameter to triggered function
domAndDowfalsebooleanCombine day-of-month and day-of-week using true = AND, false = OR (default)
legacyMode(deprecated)booleanDeprecated: Use domAndDow instead. Inverse of domAndDow (legacyMode: true = domAndDow: false).
unreffalsebooleanSetting this to true unrefs the internal timer, which allows the process to exit even if a cron job is running.
utcOffsetundefinednumberSchedule using a specific utc offset in minutes. This does not take care of daylight savings time, you probably want to use option timezone instead.
protectundefinedboolean|FunctionEnabled over-run protection. Will block new triggers as long as an old trigger is in progress. Pass either true or a callback function to enable
alternativeWeekdaysfalsebooleanEnable Quartz-style weekday numbering (1=Sunday, 2=Monday, ..., 7=Saturday). When false (default), uses standard cron format (0=Sunday, 1=Monday, ..., 6=Saturday).
allowPastfalsebooleanIf true, date-based jobs scheduled in the past will fire immediately. If false, only jobs scheduled within the past second will fire (to handle timing edge cases).
dayOffset0numberOffset the scheduled date by a number of days. Positive values shift forward, negative values shift backward. For example, dayOffset: -1 schedules one day before the pattern match. nextRun(), nextRuns(), previousRuns(), msToNext(), enumerate(), startAt and stopAt all refer to the shifted run time.
mode"auto"stringControls how the cron pattern field count is interpreted. Options: "auto" (detect automatically), "5-part" (minute-level), "6-part" (second-level), "7-part" (second+year), "5-or-6-parts", "6-or-7-parts".
sloppyRangesfalsebooleanIf true, allows non-standard stepping formats for backward compatibility (e.g. /10, 5/5, 30/30). When false (default), only */step or min-max/step formats are allowed.

Unreferencing timers (option unref) is only supported by Node.js and Deno. Browsers have not yet implemented this feature, and it does not make sense to use it in a browser environment.