Deplo

Cron jobs

Scheduled commands inside an app or database container, their runs and the master switch per target.

A job runs a command inside a running container on a cron schedule. Every job belongs to one target, an app or a database, and targetKind names which ("app" or "database"). Runs and their output are gated on manage_crons, not on view: stdout can carry whatever the command printed.

Reading

appCronJobs

Needs manage_crons. Returns CronJobsView.

An app's cron jobs, its master switch and its pickable services.

ArgumentTypeDescription
appIdID!
query {
  appCronJobs(appId: "prj_9f1c2ab7d3e4f5a6") {
    enabled
    services
    jobs {
      id
      name
      schedule
    }
  }
}

databaseCronJobs

Needs manage_crons. Returns CronJobsView.

A database's cron jobs and its master switch.

ArgumentTypeDescription
databaseIdID!
query {
  databaseCronJobs(databaseId: "db_9f1c2ab7d3e4f5a6") {
    enabled
    services
    jobs {
      id
      name
      schedule
    }
  }
}

cronRuns

Needs manage_crons. Returns [CronRun!].

One job's run history, newest first. Gated on manage_crons and not on view: stdout can carry whatever the command printed.

ArgumentTypeDescription
jobIdID!
limitInt
query {
  cronRuns(jobId: "cron_9f1c2ab7d3e4f5a6") {
    id
    status
    exitCode
    startedAt
  }
}

Jobs

createCronJob

Needs manage_crons. Returns CronJob.

Add a job to an app or a database. targetKind is app or database.

ArgumentTypeDescription
inputCronJobInput!
input.commandString
input.descriptionString
input.enabledBoolean
input.env[CronJobEnvInput!]Replaces the job's variables wholesale when present.
input.keepRunsInt10 to 500.
input.maxAttemptsInt1 to 4. 1 means no retry.
input.nameString
input.overlapStringskip | allow.
input.scheduleString5-field cron.
input.serviceStringEmpty => the target's own container.
input.shellStringsh | bash.
input.timeoutSecondsIntPer attempt, 1s to 24h.
input.timezoneStringIANA zone, e.g. Europe/Rome.
input.userString
input.workdirString
targetIdID!
targetKindString!app | database.
mutation {
  createCronJob(
    targetKind: "app"
    targetId: "prj_9f1c2ab7d3e4f5a6"
    input: { name: "nightly-report", schedule: "0 3 * * *", command: "node scripts/report.js", timezone: "Europe/Rome" }
  ) {
    id
    name
    nextRunAt
  }
}

updateCronJob

Needs manage_crons. Returns CronJob.

Edit a job. Every omitted field is left as it is.

ArgumentTypeDescription
idID!
inputCronJobInput!
input.commandString
input.descriptionString
input.enabledBoolean
input.env[CronJobEnvInput!]Replaces the job's variables wholesale when present.
input.keepRunsInt10 to 500.
input.maxAttemptsInt1 to 4. 1 means no retry.
input.nameString
input.overlapStringskip | allow.
input.scheduleString5-field cron.
input.serviceStringEmpty => the target's own container.
input.shellStringsh | bash.
input.timeoutSecondsIntPer attempt, 1s to 24h.
input.timezoneStringIANA zone, e.g. Europe/Rome.
input.userString
input.workdirString
mutation {
  updateCronJob(
    id: "cron_9f1c2ab7d3e4f5a6"
    input: { name: "nightly-report", schedule: "0 3 * * *", command: "node scripts/report.js", timezone: "Europe/Rome" }
  ) {
    id
    name
    schedule
    enabled
    nextRunAt
  }
}

deleteCronJob

Needs manage_crons. Returns Boolean.

Delete a job and its run history.

ArgumentTypeDescription
idID!
mutation {
  deleteCronJob(id: "cron_9f1c2ab7d3e4f5a6")
}

setCronEnabled

Needs manage_crons. Returns Boolean.

Turn cron jobs on or off for one target. Off stops the schedule and keeps the jobs; runs already in flight are left to finish.

ArgumentTypeDescription
enabledBoolean!
targetIdID!
targetKindString!app | database.
mutation {
  setCronEnabled(targetKind: "app", targetId: "prj_9f1c2ab7d3e4f5a6", enabled: false)
}

Runs

runCronJobNow

Needs manage_crons. Returns CronRun.

Run a job now, outside its schedule. Honours the overlap setting: while a run is in flight, a job set to skip answers with a skipped run.

ArgumentTypeDescription
idID!
mutation {
  runCronJobNow(id: "brun_9f1c2ab7d3e4f5a6") {
    id
    status
    exitCode
    startedAt
  }
}

cancelCronRun

Needs manage_crons. Returns Boolean.

Stop a run that is in flight.

ArgumentTypeDescription
idID!
mutation {
  cancelCronRun(id: "brun_9f1c2ab7d3e4f5a6")
}

See also

Did this page help you?

On this page