Schedules and alerts

功能性的

Run notebooks on this computer's own scheduler with retries, and get desktop or webhook alerts when a run fails or a check or KPI changes state.

What scheduled runs leave behind: the History rail lists each run with its tests, a hand-started run joins the same list, and two scheduled runs compared say the SQL stayed the same but the data changed and a check broke.

Real recording · typing sped up · Northwind demo data

Open the walkthrough on its own page

A schedule runs a notebook at set times on this computer's own scheduler: launchd on macOS, a systemd user timer on Linux (crontab when systemd isn't available), and Task Scheduler on Windows. Each run is recorded like any other run, and alerts go to a desktop notification or a webhook when something starts or stops going wrong.

Runs only while this computer is on. There is no SQLly cloud runner. If the computer is asleep or off at a scheduled time, that run doesn't happen then. On macOS (launchd) and Windows (Task Scheduler) jobs run only while you are logged in; on Linux a systemd user timer also stops when you log out, unless lingering is on for your user: add --enable-linger when you add the schedule (or run loginctl enable-linger yourself) to keep it running after logout. SQLly never turns lingering on without being asked, and when it is off the install message warns: "systemd user timers stop when you log out, so this job only runs while you are logged in; add --enable-linger (or run `loginctl enable-linger`) to keep it running after logout". A missed systemd run catches up once at your next login (at the next boot when lingering is on).

Schedules are managed with the CLI (sqlly-cli notebook); the app has no schedule editor yet.

Add a schedule

sqlly-cli notebook schedule add revenue.sqllynb \
  --cron "0 7 * * 1-5" --tz Europe/London \
  --param-set weekday.json \
  --notify desktop --notify webhook:https://hooks.example.com/sqlly \
  --quiet-hours 22:00-07:00
  1. The notebook must be fully trusted, as it will run. Trust it in the app first, or pass --trust, which saves the grant for scheduled runs. If the notebook's SQL or connections change afterwards, scheduled runs stop until you trust it again.
  2. No cells that change data. A notebook with any cell allowed to write is refused, because nobody is there to review the change.
  3. Production needs saying so. A cell on a connection marked production is refused unless you pass --allow-production (read-only cells only).
  4. Every connection must be mapped and allowed. Questions the app would ask you become refusals, since a scheduled run can't ask.
  5. The job is saved and installed with the OS scheduler. --no-install saves it and prints what would be installed instead; --backend launchd|systemd|cron|schtasks picks the scheduler.
--cron
Five fields, minute hour day-of-month month day-of-week: values, ranges (1-5), steps (*/15), lists, month and day names (jan, mon), and the shorthands @hourly, @daily, @midnight, @weekly, @monthly, @yearly. As in classic cron, when both day fields are restricted a day matches if either does.
--tz
An IANA time zone such as Europe/London; default is this computer's zone. When the clock jumps forward over a scheduled time, the job runs once at the jump; when it falls back, the job runs once, at the first occurrence.
--param, --param-set, --connection, --cells, --timeout
The same as for notebook run.
--retain
Output snapshots kept, newest first (default 20).
--retries, --backoff
Extra attempts after a run that errored (default 2), starting --backoff seconds later (default 60) and doubling each time, up to an hour. A refusal or usage problem is not retried.
--breaker-after
Pauses the job after this many failed runs in a row (default 5; 0 never pauses). schedule run-now <job> runs it by hand and resumes it.

Where the OS scheduler can't express a job's times (a time zone other than the computer's on macOS or Windows, a rule that needs both day fields, every-minute jobs, or more trigger entries than launchd or Task Scheduler take), SQLly installs one job that wakes every minute and runs whatever is due. Missed times collapse into one run.

sqlly-cli notebook schedule list
sqlly-cli notebook schedule run-now <job>
sqlly-cli notebook schedule remove <job>

警示

--alert-on picks the rules, comma-separated; the default is failure,assertion,kpi:

failure
A cell failed or the run could not start.
assertion
A check in a Tests cell failed.
kpi
A KPI crossed its warning or critical threshold.
incomplete
A result was cut short by a row limit, sampled, or partial. Off unless you add it.
  • Only on changes. An alert goes out when a condition starts, with one recovery note when it stops, not on every run while it stays the same.
  • No false alarms from partial data. Checks and KPIs computed from incomplete data never alert unless you pass --include-incomplete. A check whose input failed is blocked, so only the failure alerts.
  • Quiet hours. 使用 --quiet-hours 22:00-07:00, only critical alerts go out during those hours; the rest are sent at the first run afterwards if they still hold.
  • Severity. --min-severity info|warning|critical (default warning) drops anything below it.

Where alerts go

--notify desktop
A notification from the operating system: Notification Center on macOS, a toast on Windows, notify-send on Linux. Notebook titles and cell names are passed as text, never as part of a command, so a notebook can't use them to run anything.
--notify webhook:https://…
A JSON POST to an HTTPS URL, with a 10-second timeout and no redirects followed. URLs with a user name or password in them are refused. Webhook addresses often carry a token, so the address is kept in your system keychain, not in the schedule file, and schedule remove deletes it. Adding a webhook fails with a clear error when no keychain can be reached (for example headless Linux without a Secret Service). The body names the job, the notebook title, the run id and each alert, with cell names and counts only: never values, SQL or connection details.
{"source": "sqlly-notebook", "job": "…", "notebook": "Revenue review", "run_id": "…", "alerts": [ … ]}
No email. SQLly can't send alert email: it would need a mail client that isn't part of the app today. Point a webhook at a mail or chat service (most have an incoming-webhook address) instead.

A delivery problem (no network, the webhook is down) is logged as a warning and never fails the run.

Where schedules live

Jobs are kept in schedules.json in the notebook data folder, written atomically and readable only by you, with webhook addresses replaced by a reference to their keychain entry; each job's state (failures in a row, whether it is paused, which alerts are firing) is kept next to it, and launchd jobs log to logs/<job>.log. Every scheduled run is checked against the notebook's trust and recorded in the notebook audit log, like a run from the app.

限制

  • Runs happen only while this computer is on (see above).
  • Retries wait inside the scheduled run, so a job with long backoffs keeps its process running while it waits.
  • Only SQL, Tests, KPI and data attachment cells run headless, and a scheduled run reads attachment files only from inside the notebook's folder; see What the CLI runs.
  • No email alerts, as above.