Scheduled work guide

Run a proven action at the right time.

Create a task with a valid action, schedule, input, and user context. Load it at server startup and verify its behavior before making it recurring.

  • Cron
  • Intervals
  • User context

A runnable task needs five things.

Existing action

action_name must resolve on the target entity_name and succeed when called directly.

Valid schedule

Use a five-field cron expression, a descriptor such as @daily, or an interval such as @every 5m.

Execution user

Link as_user_id. Tasks without user context do not execute.

Active state and restart

Set active and restart the latest release after creating or changing tasks so the scheduler registers them.

Create, then observe one run.

{
  "name": "daily_cleanup",
  "action_name": "cleanup_old_data",
  "entity_name": "session",
  "schedule": "@daily",
  "active": true,
  "attributes": "{\"days_old\":30}",
  "as_user_id": "scheduler@example.com"
}

Link the task to the intended user through as_user_id. Start with @every 1m in an isolated environment, observe the result, then change to the production schedule and restart.

Verify the background identity.

  • The linked user still exists and has the groups required by the action.
  • An inactive task does not run.
  • An invalid schedule or action does not silently appear successful.
  • Action input arrives with the intended types and values.
  • Database work commits on success and rolls back on returned failure.
  • External side effects are made retry-safe by the action design.
  • Multiple Daptin instances do not produce unintended duplicate business effects.

Repeat safely

Assume a scheduled operation can run again.

Choose an explicit as_user_id whose permissions match the work, then restart after creating or changing the schedule. Exercise the action manually before waiting for the clock.

  • Confirm inactive and malformed schedules do not run.
  • Make external effects idempotent, especially with several server instances.
  • Record a durable business key when duplicate work would matter.
  • Verify database rollback separately from irreversible provider calls.

Build the action before scheduling it.