Deploy
Cron jobs
A cron job is built like a web service but has no URL and no port. Each run is a fresh container, and its exit code says whether the run passed.
Create one
In an environment, choose New service → Cron job, then pick GitHub or an upload. Or from the CLI:
terminal
npx @pherwerz/cloud deploy service ./jobs \
--cron "0 2 * * *" --command "node nightly.js" --timezone Africa/Lagos- Command: what each run executes, with
sh -c. Left empty, the image's own start command runs. - Schedule: a 5-field cron expression and a time zone. Runs can be 5 minutes apart at the closest.
- Timeout: 1 hour by default, 24 hours at most.
--cron, --command and --timezone only apply when the job is created.
Change them on the job's Settings tab afterwards; no rebuild is needed.
Each run
Every run gets PHZ_CRON_SCHEDULED_AT, PHZ_CRON_RUN_ID and
PHZ_CRON_MANUAL (true for Run now), and reaches the environment's
databases by name.
| Status | Means |
|---|---|
| Succeeded / Failed | It ran; Failed carries the exit code |
| Timed out | Stopped at its timeout |
| Skipped | Due, but no build yet, or the last run was still going |
| Missed | Due, but the server was offline |
Run it from CI
terminal
npx @pherwerz/cloud cron run nightlyThis follows the run's log and exits with its exit code. When a job fails a set number of times in a row (3 by default), the project's owners get one email.