Scheduling

Run tasks on a schedule with cron expressions or intervals. Supports in-process scheduling, distributed locking, and persistent job histories.

cronrecurringtimersperiodic

Providers

node-cron

Lightweight in-process cron scheduler for Node.js

node-cron

Croner

Modern cron scheduler with timezone support and overrun protection

croner

BullMQ

Redis-backed scheduled jobs with persistence and distributed execution

bullmq
REDIS_URL

Usage

Schedule a recurring task

Run a task on a cron schedule

import { scheduler } from '@/lib/schedule'

// Run every day at midnight
scheduler.register('cleanup-expired-tokens', '0 0 * * *', async () => {
  const deleted = await db.delete(tokens)
    .where(lt(tokens.expiresAt, new Date()))
  logger.info(`Cleaned up ${deleted.rowCount} expired tokens`)
})

Get Started

Add scheduling to your Primstack project with a single command:

prim schedule init