Skip to content

Deploying

Jobs and schedules

Run code that starts, does its work and exits, on demand or on a cron schedule.

A job is code that runs to completion: a batch import, a report, a cleanup task, a nightly sync. Elula builds it the same way as a service and deploys it as a Cloud Run job in your Google Cloud project. Jobs have no URL and don't serve HTTP.

ServiceJob
Use whenThe app answers HTTP requestsThe code runs and exits
Gets a URLYesNo
Started byIncoming trafficelula job run, the dashboard, or a schedule
ScalingInstances scale with trafficOne run at a time

Create and build a job

Jobs are created with the CLI:

elula init --type job
elula deploy

elula deploy builds the image and creates or updates the job definition. It doesn't run the job. Builds work exactly as for services. See Frameworks and Dockerfiles.

Note: A job must be deployed at least once before it can be run or scheduled.

Exit code 0 means the run succeeded. Any other exit code marks it as failed.

Run a job

elula job run            # start a run and wait for it to finish
elula job run --no-wait  # start a run and return right away

elula job run exits with code 1 if the run fails or is cancelled, so you can use it in scripts. Pressing Ctrl+C stops watching but the run keeps going.

In the dashboard, open the app's Jobs tab and click Run now.

Only one run can be in progress at a time. Starting another returns "A job execution is already in progress".

See and cancel runs

elula job list               # recent runs: ID, status, commit, start time
elula job list --limit 25
elula job list --json
elula job cancel 9b1c        # cancel a running run (ID or ID prefix)

Run statuses are pending, running, succeeded, failed and cancelled. elula status also shows the latest run.

Limits

  • Each run has a 10-minute time limit. A run that hasn't finished by then is marked as failed.
  • Failed runs are not retried automatically.

Resources

Jobs use the CPU and memory set on the app's Scaling tab. Instance and concurrency settings don't apply to jobs. See Scaling and resources.

Jobs get the app's environment variables, secrets and DATABASE_URL, like services. See Environment variables and secrets.

Schedules

A schedule runs the job on a cron expression. Elula creates the schedule in Cloud Scheduler in your Google Cloud project.

elula job schedule add --cron "0 9 * * 1-5"
elula job schedule add --cron "0 9 * * 1-5" --timezone "Asia/Kuala_Lumpur" --description "Daily digest"
elula job schedule add --cron "*/30 * * * *" --no-enabled   # create it paused
  • --cron takes a standard 5-field expression: minute, hour, day of month, month, day of week.
  • --timezone takes any IANA name, such as UTC, Europe/Berlin or America/New_York. The default is UTC.

Manage existing schedules by ID or ID prefix:

elula job schedule list
elula job schedule update 4d2e --cron "0 10 * * 1-5"
elula job schedule update 4d2e --timezone "America/New_York"
elula job schedule update 4d2e --description "Weekday report"
elula job schedule pause 4d2e
elula job schedule resume 4d2e
elula job schedule delete 4d2e     # asks for confirmation

A new or changed schedule is synced in the background and may take a few seconds to take effect. elula job schedule list shows each schedule's cron, timezone, whether it is enabled, and when it last ran.

The dashboard's Jobs tab lists the app's schedules. Add and change them with the CLI.

Common problems

  • "This project is a service, not a job": the folder is linked to a service. Job commands only work on apps created with --type job.
  • "Job not built yet": run elula deploy first.
  • A schedule doesn't fire at the time you expect: check its timezone with elula job schedule list. The default is UTC.