bext-plugin-cron

Scheduled tasks with cron expressions and distributed locking.

$ bext plugin add cron
Version 1.0.0
Sandbox wasm
Author bext-team
License MIT
Downloads 3,514
Updated 2026-03-08

Run scheduled tasks in your bext app using cron expressions. Tasks run in the WASM sandbox. When running multiple bext instances, distributed locking ensures each job runs exactly once.

Install

bext plugin add cron

Config

[plugins.cron]

[[plugins.cron.jobs]] name = "cleanup" schedule = "0 3 * * *" # 3am daily handler = "src/jobs/cleanup.ts"

[[plugins.cron.jobs]] name = "digest" schedule = "0 9 * * 1" # 9am every Monday handler = "src/jobs/weekly-digest.ts" ```

Job handlers

Export a default async function:

export default async function cleanup() {
  // delete expired sessions, old logs, etc.
  const deleted = await db.sessions.deleteExpired();
  return { deleted }; // return value is logged
}

Distributed locking

When `redis_url` is set and you run multiple bext instances, the plugin uses a Redis lock to ensure each scheduled job runs on exactly one instance. The lock TTL matches the cron interval, so if an instance crashes mid-job, the next instance picks it up.

Monitoring

Job runs are logged with their name, duration, and return value. Access the log at `GET /_cron/history` (JSON).