I need a cron job to run every 5 minutes. If an earlier cron job is still running, another cron job should not start. I tried setting concurrency policy to Forbid, but then the cron job does not run at all.
spec:
concurrencyPolicy: Allow
schedule: '*/5 * * * *'
spec:
concurrencyPolicy: Forbid
schedule: '*/5 * * * *'
spec:
concurrencyPolicy: Forbid
schedule: '*/5 * * * *'
startingDeadlineSeconds: 10
Could someone please help me here?
From kubernetes documentation
Concurrency Polic specifies how to treat concurrent executions of a job that is created by this cron job. The spec may specify only one of the following concurrency policies:
Allow (default): The cron job allows concurrently running jobs
Forbid: 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
Replace: 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
In your case 'concurrencyPolicy: Forbid' should work. It will not allow new job to be run if the previous job is still running. The problem is not with concurrencyPolicy in your case.
It might be related to startingDeadlineSeconds. can you remove it and try