Cron jobs
Build a command once and run it on a schedule with execution history and logs.
A cron job starts a fresh execution when its schedule is due. Use it for periodic reports, cleanup, synchronization, or commands such as Laravel's schedule:run. The command should finish and exit; continuous queue consumers belong in a background worker.
Create a cron job
- Create a Cron Job and select a repository or image.
- Configure its build and the command to execute. Repository-based jobs require an explicit start command.
- Choose a paid instance plan, then add variables and secret files.
- Enter a five-field cron expression, an IANA time zone, and a timeout.
- Review the upcoming occurrences shown in the dashboard and build the job.
The first successful build provides the image and environment used for subsequent executions. Cron jobs do not keep a permanent application instance listening between runs.
Write a schedule
The five fields are minute, hour, day of month, month, and day of week.
| Schedule | Meaning |
|---|---|
*/15 * * * * | Every 15 minutes |
0 * * * * | At the start of each hour |
0 9 * * 1-5 | At 09:00 on weekdays |
0 2 1 * * | At 02:00 on the first day of each month |
Choose UTC for a schedule independent of local daylight-saving changes. Choose a zone such as Africa/Lagos when the schedule should follow that zone's local time. Always inspect the displayed next runs, especially around clock changes.
Understand executions
Only one execution runs at a time for a given cron service. If schedules are missed while work is delayed, Openstead coalesces them instead of replaying every missed interval. At most one scheduled execution waits behind an active run.
Manually triggering a cron job replaces its active or pending execution. Check the run history before using the manual trigger on work that must finish uninterrupted.
Each execution uses the last successful build's command, variables, and secret files, and has access to the project's permitted private network. Editing the schedule or timeout takes effect without rebuilding. Deploy a new build to apply command or environment changes.
Timeouts and results
The cron timeout can be between one second and 12 hours. A successful command exits with code 0; nonzero exit codes indicate failure. Use the run history to inspect output, start and finish times, and the exit code.
Design scheduled work to tolerate retries and partial completion. Scheduling is not an exactly-once guarantee for external side effects such as charging a customer or sending an email. Use application-level deduplication.
Do not rely on files left by an earlier execution. Store durable state in a database or object storage. Suspending the service prevents new scheduled work until it is resumed.