Skip to content
Development documentation
This describes Keydra as it is being built and is not a released version. What it documents can change before a release.

Scheduled work

A job, a target, a cadence and a switch — with the credentials already here and a run that stops being something you find out about.

What a schedule is#

A schedule is a job, a target, a cadence and a switch. A run is one attempt, with what it did and whether it worked.

Scheduled work, with each schedule’s job, target, cadence and next run

Everything else — which keys, which second target, how many at a time — belongs to the job’s own settings, because the jobs have little in common beyond being worth repeating.

The kinds of work available:

Name Description

FLUSH_DATABASE

Empties a database on the target. The job everybody has a shell script for, and the one everybody has run against the wrong server at least once — so it names its target and asks for it by name.

COPY_KEYS

Copies keys to another target, on a cadence. The same code a migration started by hand uses, so a nightly copy and a manual one behave identically.

EXPORT_KEYS

Writes keys, values and expiries to a file. With a backup destination configured, the file leaves the machine and old ones fall off the end.

Permissions#

A schedule requires the permission its job would need if somebody ran it by hand, and schedule:manage on the target. Both are checked when it is saved and again when it runs. A schedule is a way of doing something later, not a way of doing something you may not do.

Runs are recorded before they start#

A job that never finishes is visible as one that never finished, rather than as one that never ran.

A failed run raises a notification. Successful ones do not — a toast every five minutes would bury the one that matters — but the page’s "last run" column changes either way.

Creating a schedule#

Prerequisites
  • schedule:manage on the target, plus the permission the work itself requires — for example keys:delete for a flush, transfer:export for an export, migration:run for a copy.

Procedure
  1. Go to Scheduled work.

  2. Click New schedule.

  3. Give it a name and choose the target.

  4. Choose the kind of work and complete its settings.

  5. Give the cadence as a cron expression.

  6. Save it, enabled.

Verification

The row appears with its cadence and next run. Click Run now to prove it does what you meant before waiting for the clock — which is what everybody does the moment they have written one.

Important:Important

Flush a database is the job everybody has a script for, and the one everybody has run against the wrong target at least once. It names its target and asks for it by name before it will save.

Watching what ran#

Procedure
  1. Go to Scheduled work.

  2. Open a schedule’s Details to see its run history: when each run started and finished, what it touched, and what went wrong if anything did.

Verification

The list header counts the schedules that are failing, so a job that has quietly stopped working is visible from the page rather than from the empty cache it was feeding.

A failed run also arrives as a notification while you are using Keydra, wherever you are in it.

Note:Note

Where more than one Keydra runs against one database, schedules are registered only on the instance holding the lease. A job that fires during a handover runs once, on whichever instance holds it then.

Edit this page