Run tasks on a schedule with cron expressions or intervals. Supports in-process scheduling, distributed locking, and persistent job histories.
Lightweight in-process cron scheduler for Node.js
Modern cron scheduler with timezone support and overrun protection
Redis-backed scheduled jobs with persistence and distributed execution
REDIS_URLSchedule 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`)
})Add scheduling to your Primstack project with a single command:
prim schedule init