Skip to content
Krzysztof Słysz edited this page Nov 23, 2026 · 2 revisions

Jobs

Required user role: ADMIN

A job runs a saved task on one bucket. It can run:

  • by itself, on a schedule (cron) - every night, every hour, on weekdays at 6:00... (since 3.21.0),
  • by its keyword, together with other jobs - one call runs all the jobs of a keyword, e.g. DEV cleaning before a test run (since 3.23.0),
  • on demand - the Run button.

For example:

  • release the reservations older than 2 hours (every hour),
  • move the rows marked as used to the trash every night,
  • DEV cleaning: remove all rows of a few buckets and release the reservations in others, called by the CI pipeline before the tests.

Add jobs in Settings → Jobs.

Job fields

  • Name - job name (*)
  • Description - explanatory description
  • Task - the task to run: its action (modify, remove, clear history or reserve) and its filter
  • Bucket - the bucket the task runs on; the task must be available in it (Show in buckets or Show by classes of the task)
  • Rules - optional rules narrowing the filter of the task, in the format of the API rules, e.g. [["modifiedAt", "<", "@now-2h"]]
  • Cron - when the job runs by itself (see below); empty = never by itself
  • Keyword - the keyword of the job, e.g. DEV cleaning (see below); empty = none. The field suggests the keywords already used.
  • Time zone - the time zone of the cron, e.g. Europe/Warsaw or UTC; a new job gets the time zone of your browser
  • Enabled - the cron runs the job only when enabled; Run and the keyword run a disabled job too
  • Cron runs as - the user the cron runs the task as: the one who saved the job last (read only)
  • Next run - when the cron runs the job next
  • Last run - when it ran last (by any way), with ✔ or ✖ and the number of rows; the tooltip shows the message
  • Modified by, Modified at

(*) Shown in the history and in the logs.

A job with neither a cron nor a keyword runs only by Run.

Which rows

The task runs on the rows matching the filter of the task and the rules of the job, both together. A task without a filter needs rules, so a job never runs on the whole bucket by mistake. To run on all rows on purpose, give a rule that every row matches, e.g. [["id", ">", 0]]. The rules can use relative dates: @now, @now-2h, @now-1d, @now+1w (units s, m, h, d, w) - see Functions.

Examples:

The task Rules of the job Cron Keyword
release (modify: set reserved = false), no filter [["reserved", "==", true], ["modifiedAt", "<", "@now-2h"]] 0 * * * * (every hour)
trash used (modify: set the tag trash), filter tag is used 0 2 * * * (every day at 2:00)
remove (remove), no filter, bucket orders-dev [["id", ">", 0]] DEV cleaning
release (modify: set reserved = false), no filter, bucket users-dev [["reserved", "==", true]] DEV cleaning

Cron

Five fields, separated by spaces: minute hour day-of-month month day-of-week.

Cron Runs
0 2 * * * every day at 2:00
*/15 * * * * every 15 minutes
0 6 * * MON-FRI on weekdays at 6:00
30 7 1 * * on the first day of the month at 7:30
0 */4 * * * every 4 hours

A cron with six fields (the second first, as in Spring) is accepted too. A job runs by cron at most once a minute. When the server was down at the time of a run, the job runs once when the server is up again (not once for every missed time).

Keyword

Jobs with the same keyword run together, in one call:

  • in Settings → Jobs → Run keyword (▶≡ above the table): choose the keyword, Preview shows how many rows each job would run on, Run runs them and shows the result of each job,
  • from the API: POST /api/task-schedules/run (see below),
  • by an AI agent: the tool run_jobs.

The jobs run one after another, by id, as the user who called (see below). A job that fails doesn't stop the others: its error is in the result and in the job's history. The keyword is compared ignoring case and the spaces around it (dev cleaning = DEV cleaning). A job has one keyword.

The same keyword runs once at a time in a project: a second call while the jobs run is refused (the jobs of the keyword are running), also with several Databucket instances.

Who the task runs as

  • The cron runs the task as the user who saved the job last (Cron runs as), with that user's access to the bucket. When another admin saves the job, the cron runs it as them from then on. A run fails when that user can't sign in to the project any more (disabled, expired, removed from the project).
  • Run and the keyword run the task as the user who called: their access to the bucket and their role apply, and their name is in the history and in Modified by of the changed rows.

Saving a job

Saving checks the job the way it will run: the task must be one of the bucket's tasks, you must have access to the bucket and the role the task needs (removing rows and clearing the history: ROBOT or higher, which every ADMIN has), and the rules must be valid. A job that wouldn't run can't be saved; the message says why.

Run and executions

  • Run (▶ in the row) runs the job at once, also a disabled one, and shows the result. Use it to try a new job.
  • Executions (🕘 in the row) shows the last 100 runs: when, how (Cron, Run or Keyword), by whom, the result, the number of rows, the duration and the message.

Safety

  • A run that would change or remove more than 10 000 rows fails instead and changes nothing (databucket.task-schedules.max-rows). Narrow the rules, or raise the limit.
  • After 5 failed cron runs in a row the job is disabled (databucket.task-schedules.max-failures); the last message says why. A run that works resets the count; failures of Run and of the keyword don't count (the caller sees them). Enabling the job again starts the count from zero.
  • A task used by a job can't be removed. Removing a bucket removes its jobs.

Configuration

The defaults, in the configuration file (see Installation):

databucket:
  task-schedules:
    enabled: true        # false: no job runs by cron (Run and the keyword still work)
    poll-interval: 60s   # how often the server looks for jobs to run by cron
    max-rows: 10000
    max-failures: 5
    history-size: 100    # runs kept per job

With several Databucket instances (e.g. in Kubernetes) each cron run happens once: the instance that takes a job locks it in the database.

Every run is also written to the log, as task.schedule-run (and task.run), a keyword call as task.keyword-run, see Logging.

From the API

Run the jobs of a keyword, e.g. from a CI pipeline before the tests - ROBOT or higher:

POST /api/task-schedules/run
{"keyword": "DEV cleaning"}

The response lists each job, by id:

{
  "keyword": "DEV cleaning", "preview": false, "ok": 1, "errors": 1,
  "jobs": [
    {"id": 4, "name": "Clean orders", "task": "remove", "bucket": "orders-dev", "status": "OK", "count": 120, "message": "Removed 120 data row(s)"},
    {"id": 7, "name": "Release users", "task": "release", "bucket": "users-dev", "status": "ERROR", "count": null, "message": "There is no bucket 'users-dev' you have access to"}
  ]
}
  • ?preview=true changes nothing: count is the number of rows each job would run on.
  • 200 also when some jobs failed - check errors; 404 - no job has the keyword (the message lists the keywords); 409 - the jobs of the keyword are running; 400 - no keyword.
  • The jobs run as the caller: give the robot access to the jobs' buckets.

A saved task can also be run by itself, without a job: POST /api/bucket/{bucketName}/tasks/{taskId}/run - see Get started with API.

Clone this wiki locally