Questo contenuto non è disponibile nella lingua selezionata.

Chapter 32. Scheduled Jobs


32.1. Overview

A scheduled job builds on a regular job by allowing you to specifically schedule how the job should be run. Scheduled jobs are part of the Kubernetes API, which can be managed with oc commands like other object types.

Note

As of OpenShift Container Platform 3.3.1, Scheduled Jobs is a feature in Technology Preview.

32.2. Creating a Scheduled Job

A scheduled job configuration consists of the following key parts:

  • A schedule specified in cron format.
  • A job template used when creating the next job.
  • An optional deadline (in seconds) for starting the job if it misses its scheduled time for any reason. Missed jobs executions will be counted as failed ones. If not specified, there is no deadline.
  • ConcurrencyPolicy: An optional concurrency policy, specifying how to treat concurrent jobs within a scheduled job. Only one of the following concurrent policies may be specified. If not specified, this defaults to allowing concurrent executions.

    • Allow allows Scheduled Jobs to run concurrently.
    • Forbid forbids concurrent runs, skipping the next run if the previous has not finished yet.
    • Replace cancels the currently running job and replaces it with a new one.
  • An optional flag allowing the suspension of a scheduled job. If set to true, all subsequent executions will be suspended.

The following is an example of a ScheduledJob resource:

apiVersion: batch/v2alpha1
kind: ScheduledJob
metadata:
  name: pi
spec:
  schedule: */1 * * * ?    
1

  jobTemplate:             
2

    spec:
      template:
        spec:
          containers:
          - name: pi
            image: perl
            command: ["perl",  "-Mbignum=bpi", "-wle", "print bpi(2000)"]
          restartPolicy: Never
Copy to Clipboard Toggle word wrap
  1. Schedule for the job. In this example, a job will run every minute.
  2. Job template. This is similar to the job example.

32.3. Known Issues

32.3.1. Unable to Edit a Scheduled Job

There is a known issue when invoking oc edit scheduledjob due to an error that was already fixed in the latest version. However, due to significant code changes, this was not backported.

One possible solution is to use oc patch command instead of oc edit.

32.3.2. Unable to Change Concurrency Policy

There is a known issue when changing concurrency policy where no new jobs are created after that operation is run. The issue is still under investigation in the latest version.

Torna in cima
Red Hat logoGithubredditYoutubeTwitter

Formazione

Prova, acquista e vendi

Community

Informazioni sulla documentazione di Red Hat

Aiutiamo gli utenti Red Hat a innovarsi e raggiungere i propri obiettivi con i nostri prodotti e servizi grazie a contenuti di cui possono fidarsi. Esplora i nostri ultimi aggiornamenti.

Rendiamo l’open source più inclusivo

Red Hat si impegna a sostituire il linguaggio problematico nel codice, nella documentazione e nelle proprietà web. Per maggiori dettagli, visita il Blog di Red Hat.

Informazioni su Red Hat

Forniamo soluzioni consolidate che rendono più semplice per le aziende lavorare su piattaforme e ambienti diversi, dal datacenter centrale all'edge della rete.

Theme

© 2025 Red Hat