<p>When for whatever reasons I delete the pod running the Job that was started by a CronJob, I immediately see a new pod being created. It is only once I delete something like six times the <code>backoffLimit</code> number of pods, that new ones stop being created.</p>

<p>Of course, if I'm actively monitoring the process, I can delete the CronJob, but what if the Pod inside the job fails when I'm not looking? I would like it not to be recreated.</p>

<p>How can I stop the CronJob from persisting in creating new jobs (or pods?), and wait until the next scheduled time if the current job/pod failed? Is there something similar to Jobs' <code>backoffLimit</code>, but for CronJobs?</p>

LLlAMnYP
<p>Set <strong><code>startingDeadlineSeconds</code></strong>  to a large value or left unset (the default).</p>

<p>At the same time  set <strong><code>.spec.concurrencyPolicy</code></strong> as <strong><code>Forbid</code></strong> and the CronJobs skips the new job run while previous created job is still running. </p>

<p>If  <strong><code>startingDeadlineSeconds</code></strong>  is set to a large value or left unset (the default) and if <strong><code>concurrencyPolicy</code></strong> is set to <strong><code>Forbid</code></strong>, the job will not be  run if failed.</p>

<p>Concurrent policy field you can add to specification to defintion of your CronJob (.spec.concurrencyPolicy), but this is optional. </p>

<p>It specifies how to treat concurrent executions of a job that is created by this CronJob. The spec may specify only one of these three concurrency policies:</p>

<ul>
<li><strong>Allow (default)</strong> - The cron job allows concurrently running jobs</li>
<li><strong>Forbid</strong> - The cron job does not allow concurrent runs; if it is time for a new job run and the previous job run hasn’t finished yet, the cron job skips the new job run</li>
<li><strong>Replace</strong> - If it is time for a new job run and the previous job run hasn’t finished yet, the cron job replaces the currently running job run with a new job run</li>
</ul>

<p>It is good to know that currency policy applies just to the jobs created by the same CronJob. 
If there are multiple CronJobs, their respective jobs are always allowed to run concurrently.</p>

<p>A CronJob is counted as missed if it has failed to be created at its scheduled time. For example, If <strong><code>concurrencyPolicy</code></strong> is set to <strong><code>Forbid</code></strong> and a CronJob was attempted to be scheduled when there was a previous schedule still running, then it would count as missed.</p>

<p>For every CronJob, the CronJob controller checks how many schedules it missed in the duration from its last scheduled time until now. If there are more than 100 missed schedules, then it does not start the job and logs the error</p>

<p>More information you can find here: <a href="https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/" rel="nofollow noreferrer"><code>CronJobs</code></a> and  <a href="https://kubernetes.io/docs/tasks/job/automated-tasks-with-cron-jobs/" rel="nofollow noreferrer"><code>AutomatedTask</code></a>.</p>

<p>I hope it helps.</p>
