Schedule a job
This tutorial adds a scheduled run to an existing Resource. You will set a cron
schedule in hyjal.toml, branch your handler on the HYJAL_TRIGGER
environment variable, deploy, and watch each scheduled run land in the Logs
tab. It takes about ten minutes.
Scheduled runs are ordinary metered instances: the platform invokes the Resource on the cron cadence, the same way an HTTP request would. There is no separate worker type to provision.
Prerequisites
- A deployed Project. This tutorial uses
acmewith anapiResource on the Go lane. - The
hyjalCLI installed and logged in.
1. Add a schedule to the Resource
Open hyjal.toml and add a schedule field to the Resource you want to run
on a cadence. The value is a five-field cron expression evaluated in UTC.
The expression */15 * * * * runs the Resource every fifteen minutes. See
Jobs and crons for the full field grammar.
2. Branch the handler on the trigger
A scheduled run invokes the same component as an HTTP request. Read the
HYJAL_TRIGGER environment variable to tell them apart: it is schedule on a
scheduled run and absent (or http) on a normal request.
The line written to stdout is captured per request and appears in the Logs tab, correlated with the scheduled run.
3. Deploy
Deploy the Resource. The schedule is registered as part of applying policy.
The schedule registered line confirms the cron entry is active. The next run
fires at the next fifteen-minute boundary.
4. Watch runs in the Logs
Stream the Resourceâs logs and wait for the next scheduled boundary, or open the Logs tab in the Console.
Each scheduled run is a row in the same chronological table as HTTP requests,
with its method shown as SCHEDULE. The stdout line is attached to the run.
Filter to scheduled runs in the Console with the method filter chips.
What you built
- A Resource that runs every fifteen minutes on a UTC cron schedule.
- A handler that branches on
HYJAL_TRIGGER=scheduleto do scheduled work separately from HTTP traffic. - Per-run visibility in the Logs tab, with stdout correlated to each run.
Next steps
- Jobs and crons: cron field grammar and external scheduler invocation.
- Environment variables: inject config and secrets into each run.
- Logs: search and filter the run timeline.