Cron jobs

Beta

Run a command on a schedule inside one of your containers.

Beta

This feature is currently beta/experimental and subject to change. It is not recommended for production. Try it out and share your feedback on our GitHub.

A nightly cleanup, a report at 6am, a queue worker tick, php artisan schedule:run.

  • The panel decides when, the agent runs it. Restarting or updating the panel does not kill a running job; while the panel is down, nothing new starts.
  • It runs in the current container of the service you picked, so a redeploy does not break it. No service picked means the app's own, the one its domain routes to.
  • It runs in sh -c or bash -c with the container's environment, as the container's user. No login shell, no profile files.
  • Each job has its own timezone, yours by default. 03:00 Europe/Rome is 03:00 in Rome, summer and winter. Backup schedules use UTC instead.

Turn it on

Cron jobs are off by default, per app and per database.

Turn on Cron jobs

Open the app or database, then Settings -> Advanced, and turn on Cron jobs.

The Cron jobs switch on Settings -> Advanced

Create the job

A Cron jobs tab appears. Open it and click New cron job.

The switch also pauses every job under it: turned off, the jobs are kept and none runs.

Create a job

The New cron job dialog: schedule, timezone, next run and command

The main fields, then Advanced for the rest:

Prop

Type

Reading the run history

The cron jobs of an app with their schedule and last result
StatusWhat it meansAlert
RunningRunning now. Retrying between attempts-
SucceededExit code 0Cron job finished
FailedIt ran and exited non-zeroCron job failed
Timed outIt hit the per-attempt timeoutCron job failed
SkippedIt never started: the container was stopped, or the previous run was still goingNone
UnknownThe agent could not report the result. Not retried, since the command may have finishedCron job failed, "outcome unknown"
Lost: its server stoppedOnly on a cluster: the server stopped while the run was going, so the command may be half done. Never retried, whatever attempts saysCron job lost with its server
  • Retries share one row: three attempts are one run with an attempt counter.
  • The stored output is the last 16 KiB of the last attempt.
  • Run now starts a run marked with who triggered it. Stop this run stops the command and everything it started.
  • A job that keeps failing alerts once every 30 minutes, not on every run.
  • Lost is not Unknown. Unknown means Deplo lost track of a run on a server that is still there, so the command most likely finished. A lost row has its own Run now, which starts a new run on the server running the app now.

Good to know

  • A job runs any code as the container's user. That is why manage_crons is a sensitive capability and the feature is off by default.
  • This is not a job queue. No dependencies between jobs, no backoff beyond Attempts.

Troubleshooting

  • Every run is Skipped: the container is stopped, or the previous run never finishes.
  • This container has no bash. Switch the job to sh.: pick sh.
  • This container has no shell, so it cannot run a cron job.: a distroless or scratch image.
  • It works in the console and fails here: the console's /bin/sh and /bin/bash start a login shell, a cron job does not. Use absolute paths, or set what is missing under Variables.
  • Runs end Unknown: the agent lost contact during the run. Check that server.

More in Servers and agents.

Next steps

Did this page help you?

On this page