Check a website every 10 minutes
A recurring schedule runs a small task every 10 minutes. Each run knows the slot it serves, a down site fails the run so you get told, and you learn to pause, change, re-run and stop a schedule.
What this tutorial proves
- A recurring schedule starts a run at each slot of a cron expression, in the time zone you choose. No server or cron of your own.
- Each run knows which slot it serves (
ctx.run.scheduled_for), so one slot can write once. - A failed run tells you (a notification), and it does not stop the schedule.
- You can change, pause, resume and stop a schedule, and run one past slot again by hand.
What you build
A small uptime check. Every 10 minutes the task asks one web page for an answer and times it.
- At each slot, the platform starts a run of the newest READY deployment of the task.
- The task sends one HTTPS request to your page and measures the time.
- An answer of 2xx or 3xx within the time budget is "up". The result holds the slot, a key for the slot, the status and the time.
- "Down" or "slow" fails the run. You see it in
run:listand as a notification.
schedule */10 * * * * ──every 10 minutes──▶ a run of uptime-check
│ ctx.run = { id, schedule_id, scheduled_for }
▼
VM: uptime-check ──HTTPS──▶ example.com (only)
│
up: result { slot, key, status, ms }
down: the run FAILS ──▶ notification "Runs are failing"The task's nature
| Setting | Value | Why |
|---|---|---|
network.type | egress | Outbound only. Nothing can connect to the task. |
egress_allow | [example.com] | The only host the task may reach. Put the host of your own page here. |
duration | short | One request: a few seconds. |
preset | std.micro | 128 MiB is enough. A run every 10 minutes is 144 runs a day, so the smallest size costs the least. |
timeout_sec | 30 | Far below the 10 minutes between slots, so a run never overlaps the next one. |
Before you start
- A plan with recurring schedules and outbound access. This tutorial uses Starter. The Free plan has no recurring schedules: a create there is refused with
capability-denied.whoamishowsmax_schedules. - The CLI, installed and signed in. See Install.
- Room in your run limits: a run every 10 minutes is 144 runs a day, and each counts like any run.
quotashows your limits. - A page to check. The example checks
https://example.com/.
$ ignitify loginCreate the task
$ ignitify task:create uptime-checkReplace the files the command made with the files below.
tasks/uptime-check/
├── task.yaml outbound access to one host, run defaults
├── index.ts the shell: the request, the timing, the result
├── utils.ts the pure parts: payload rules, the slot and its key, the verdict
└── README.md how to run itThe code
slotOf in utils.ts reads the slot. A run that a schedule started has it in ctx.run.scheduled_for, a UTC time such as 2027-01-15T02:00:00.000Z. The key sch_…:<slot> names that slot once. Use a key like this when the task writes to another system, so a retried run does not write twice. A run that you start yourself has no slot: schedule_id and scheduled_for are null, and the key is the run id.
// Uptime check: one HTTPS request to a URL, timed. A schedule runs it every few minutes.
//
// Payload: { url: "https://…" (required), max_ms?: number (default 3000), slot?: ISO time }
// Network: outbound to the URL's host only (egress_allow in task.yaml).
//
// A run that a schedule started knows its slot from ctx.run; the result carries that slot and a
// key that names it once. A down or slow site FAILS the run, so it shows in `run:list` and in
// the failed-runs notification.
//
// This file is the shell: the request and the result. The pure parts live in utils.ts.
import { parseInput, slotOf, verdict, type RunInfo } from "./utils.js";
type Ctx = {
run: RunInfo;
metric(name: string, value: number): void;
};
type CheckResult = {
url: string;
slot: string | null;
key: string;
status: number;
ms: number;
};
export async function run(payload: Record<string, unknown>, ctx: Ctx): Promise<CheckResult> {
const input = parseInput(payload);
const { slot, key } = slotOf(ctx.run, payload);
console.log(`check ${input.url} for slot ${slot ?? "none"} (key ${key})`);
const started = Date.now();
const res = await fetch(input.url, {
method: "GET",
redirect: "manual",
headers: { "user-agent": "ignitify-uptime-check" },
signal: AbortSignal.timeout(input.maxMs + 1000),
}).catch((err: unknown) => {
throw new Error(`${input.url} did not answer: ${err instanceof Error ? err.message : String(err)}`);
});
const ms = Date.now() - started;
ctx.metric("uptime_ms", ms);
const v = verdict(res.status, ms, input.maxMs);
console.log(`${input.url} ${v.reason}`);
if (!v.ok) throw new Error(`${input.url} is down for slot ${slot ?? "none"}: ${v.reason}`);
return { url: input.url, slot, key, status: res.status, ms };
}// The pure parts of uptime-check: payload rules, which slot a run serves, and the verdict.
// No I/O here, so every function is a plain input → output.
/** What the task needs, after the payload is checked. */
export type CheckInput = { readonly url: string; readonly maxMs: number };
/** `ctx.run` as the platform gives it. Null on a frame with no run (a warm-up). */
export type RunInfo = {
readonly id: string;
readonly schedule_id: string | null;
readonly scheduled_for: string | null;
} | null;
/** The slot a run serves, and the key that names it once. */
export type Slot = { readonly slot: string | null; readonly key: string };
export type Verdict = { readonly ok: boolean; readonly reason: string };
const DEFAULT_MAX_MS = 3000;
const LIMIT_MAX_MS = 20_000;
/** Check the payload: `url` is https; `max_ms` defaults to 3000, at most 20000. */
export function parseInput(payload: Record<string, unknown>): CheckInput {
const url = typeof payload.url === "string" ? payload.url.trim() : "";
if (!url.startsWith("https://")) throw new Error('payload.url must be an https URL, for example "https://example.com/"');
const raw = payload.max_ms ?? DEFAULT_MAX_MS;
const maxMs = typeof raw === "number" && Number.isInteger(raw) && raw > 0 && raw <= LIMIT_MAX_MS ? raw : NaN;
if (Number.isNaN(maxMs)) throw new Error(`payload.max_ms must be a whole number from 1 to ${LIMIT_MAX_MS}`);
return { url, maxMs };
}
/**
* Which slot this run serves. A slot you run by hand sends it in `payload.slot`; a run that a
* schedule started has it in `ctx.run.scheduled_for`. The key is the same for one slot, so a
* second write for that slot can be found and dropped.
*/
export function slotOf(run: RunInfo, payload: Record<string, unknown>): Slot {
const manual = typeof payload.slot === "string" ? payload.slot : null;
const slot = manual ?? run?.scheduled_for ?? null;
const schedule = run?.schedule_id ?? (typeof payload.schedule_id === "string" ? payload.schedule_id : null);
const key = schedule && slot ? `${schedule}:${slot}` : (run?.id ?? "local");
return { slot, key };
}
/** Up means a 2xx or 3xx answer within the time budget. */
export function verdict(status: number, ms: number, maxMs: number): Verdict {
if (status < 200 || status >= 400) return { ok: false, reason: `answered ${status}` };
if (ms > maxMs) return { ok: false, reason: `slow: ${ms} ms, over ${maxMs} ms` };
return { ok: true, reason: `answered ${status} in ${ms} ms` };
}schema_version: 1
slug: uptime-check # must match this directory's name
runtime: node
execution:
duration: short # one HTTP request: a few seconds
network:
type: egress # outbound only: nothing can connect to this task
egress_allow: [example.com] # the only host the task may reach; put your own host here
run:
payload:
url: https://example.com/
max_ms: 3000
preset: std.micro # 128 MiB is enough for one request
timeout_sec: 30# uptime-check
One timed HTTPS request to a URL. A recurring schedule runs it every 10 minutes. Each run knows the slot it serves (`ctx.run.scheduled_for`) and returns a key that names that slot once. A down or slow site fails the run.
## Files
- `task.yaml`: slug, runtime, outbound access to one host only, and run defaults.
- `index.ts`: the shell: the request, the timing and the result.
- `utils.ts`: the pure parts: payload rules, the slot and its key, and the verdict.
## Payload
| Field | Default | Meaning |
| :-- | :-- | :-- |
| `url` | `https://example.com/` (in task.yaml, for `task:run` only; a schedule needs `--payload`) | The page to check. Its host must be in `egress_allow`. |
| `max_ms` | 3000 | Slower than this is "down", at most 20000 |
| `slot` | none | A slot time you run by hand (ISO, UTC) |
| `schedule_id` | none | With `slot`: the `sch_…` id, so the key matches the schedule's own key |
## Result
`{ url, slot, key, status, ms }`. `slot` is the schedule slot in UTC, or null for a run you started. `key` is `sch_…:<slot>` for a slot, else the `run_…` id.
## Lifecycle
```bash
ignitify login
ignitify task:create uptime-check
ignitify task:validate uptime-check
ignitify task:deploy uptime-check
ignitify task:run uptime-check --wait
ignitify schedule:preview "*/10 * * * *"
ignitify schedule:create uptime-check --cron "*/10 * * * *" --payload '{"url":"https://example.com/"}'
ignitify schedule:list
ignitify run:list --schedule <sch-id>
ignitify schedule:pause <sch-id>
ignitify schedule:resume <sch-id>
ignitify schedule:cancel <sch-id> -y
```Validate, deploy and run it once
$ ignitify task:validate uptime-check✓ task config valid
$ ignitify task:deploy uptime-check$ ignitify task:run uptime-check --waitThe result has slot: null and a key that is the run id: you started this run, not a schedule.
Check the cron expression
The expression has five fields: minute, hour, day of month, month and day of week. */10 * * * * means "at minute 0, 10, 20, 30, 40 and 50 of every hour". schedule:preview prints the next fire times in UTC and makes no schedule.
$ ignitify schedule:preview "*/10 * * * *"A daily check at 09:00 in Berlin would be "0 9 * * *" with --tz Europe/Berlin. The zone follows summer and winter time. Without --tz the expression reads in UTC. The fastest repeat is once a minute.
Create the schedule
$ ignitify schedule:create uptime-check --cron "*/10 * * * *" --payload '{"url":"https://example.com/"}'✓ Schedule Createdschedule_id sch_Vb7LmQ2sXe9Kcron */10 * * * *timezone UTCoverlap skipstatus ACTIVE…
Keep the sch_… id. The run options --payload, --preset, --timeout-sec and --deadline-sec work here, and every run of the schedule uses them. Without --preset or --timeout-sec, a run uses the deployed task.yaml values (std.micro, 30 seconds). The schedule does not use run.payload of task.yaml: without --payload the payload is , and this task needs a url.
Watch it run
Wait for the next slot. Then see the schedule and the runs it started:
$ ignitify schedule:show sch_Vb7LmQ2sXe9K$ ignitify run:list --schedule sch_Vb7LmQ2sXe9K$ ignitify run:get <run-id> --json | jq .resultNow the result has the slot and the key of the schedule, for example:
{
"url": "https://example.com/",
"slot": "2027-01-15T02:10:00.000Z",
"key": "sch_Vb7LmQ2sXe9K:2027-01-15T02:10:00.000Z",
"status": 200,
"ms": 412
}schedule:show also shows last_outcome, consecutive_misses and the next fire times. schedule:list lists all your schedules, recurring and one-time.
When the site is down
Point the schedule at a page that answers 404, and wait for one slot:
$ ignitify schedule:update sch_Vb7LmQ2sXe9K --payload '{"url":"https://example.com/no-such-page"}'$ ignitify run:list --schedule sch_Vb7LmQ2sXe9K --limit 3$ ignitify notification:listThe run is FAILED, with the reason https://example.com/no-such-page is down for slot …: answered 404. When runs keep failing, a "Runs are failing" alert opens. The schedule goes on: a run that started and then failed does not count against the schedule. Put the good URL back:
$ ignitify schedule:update sch_Vb7LmQ2sXe9K --payload '{"url":"https://example.com/"}'When a slot cannot start
A slot is "missed" when it does not start a run. The common causes:
- No READY deployment of the task, or a run setting your plan does not allow.
- Your own limits, for example your running VMs are all in use by your own runs. The slot waits and tries again. If its time passes, it is missed.
- A long platform delay. You get a
schedule.missednotification with the reasondeadline-passed. After a long delay, only the newest due slot starts.
After 10 counted misses in a row, the platform pauses the schedule: status is auto_paused, and you get a notification. A wait caused by the platform, such as a host in maintenance, does not count. Find the cause in pause_reason, fix it, then resume:
$ ignitify schedule:show sch_Vb7LmQ2sXe9K --json | jq '{status, pause_reason, pause_detail, consecutive_misses}'Pause and resume
A pause stops new slots. A run that already started goes on.
$ ignitify schedule:pause sch_Vb7LmQ2sXe9K$ ignitify schedule:resume sch_Vb7LmQ2sXe9KA resume starts again from the next slot. It does not catch up the slots it missed while it was paused. A paused schedule still counts toward max_schedules.
Run one past slot again
To check a slot again by hand, start one run with the slot in the payload. A run that you start has no schedule, so the task reads payload.slot first. With schedule_id in the payload too, the key is the same as the schedule's key for that slot.
$ ignitify task:run uptime-check \
--payload '{"url":"https://example.com/","slot":"2027-01-15T02:10:00.000Z","schedule_id":"sch_Vb7LmQ2sXe9K"}' \
--idempotency-key sch_Vb7LmQ2sXe9K-2027-01-15T02-10Z --wait- The run uses the preset, the time limit and
executionthat the deployment stored from itstask.yaml, as a slot does. A slot also uses the run settings of the schedule (run_settingsinschedule:show --json). If the schedule sets a time limit, pass the same--timeout-sec. - For 24 hours, an idempotency key returns the first answer and starts nothing new. To run a failed slot again, use a new key.
Deploy a change
Change the code and deploy again. The schedule keeps its id, and its next slot runs the new deployment, because each slot runs the newest READY deployment of the task. You do not create the schedule again.
$ ignitify task:deploy uptime-checkClean up
schedule:cancel deletes a recurring schedule. The runs it started stay.
$ ignitify schedule:cancel sch_Vb7LmQ2sXe9K -y$ ignitify task:delete uptime-check --yesNext steps
- Check several pages: one schedule per page, each with its own
--payload. Two schedules of one task differ inpayload_sha256inschedule:show --json. - Get told at once: add an end-of-run callback with
notify:setand post a failed check to your chat tool. - Manage the schedule as code: the ignitify_schedule Terraform resource.
- Read the full guide: Run on a schedule, and the schedule commands.