# Source: https://docs.datadoghq.com/security/code_security/iac_security/iac_rules/terraform/kubernetes/cronjob_deadline_not_configured.md

# Source: https://docs.datadoghq.com/security/code_security/iac_security/iac_rules/k8s/cronjob_deadline_not_configured.md

---
title: CronJob deadline not configured
description: Datadog, the leading service for cloud-scale monitoring.
breadcrumbs: >-
  Docs > Datadog Security > Code Security > Infrastructure as Code (IaC)
  Security > IaC Security Rules > CronJob deadline not configured
---

# CronJob deadline not configured

{% callout %}
# Important note for users on the following Datadog sites: app.ddog-gov.com

{% alert level="danger" %}
This product is not supported for your selected [Datadog site](https://docs.datadoghq.com/getting_started/site). ().
{% /alert %}

{% /callout %}

## Metadata{% #metadata %}

**Id:** `192fe40b-b1c3-448a-aba2-6cc19a300fe3`

**Cloud Provider:** Kubernetes

**Platform:** Kubernetes

**Severity:** Low

**Category:** Resource Management

#### Learn More{% #learn-more %}

- [Provider Reference](https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/)

### Description{% #description %}

CronJobs must have a configured deadline. The `startingDeadlineSeconds` attribute must be defined. This attribute specifies the time window, in seconds relative to the scheduled start time, within which a missed job may still be started. Omitting `spec.startingDeadlineSeconds` leaves the CronJob without a configured deadline for missed starts, which can result in delayed or unpredictable job executions; define `spec.startingDeadlineSeconds` with an appropriate value to ensure predictable scheduling.

## Compliant Code Examples{% #compliant-code-examples %}

```yaml
apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: hello
spec:
  schedule: "*/1 * * * *"
  startingDeadlineSeconds: 100
  jobTemplate:
    spec:
      template:
        spec:
          containers:
          - name: hello
            image: busybox
            args:
            - /bin/sh
            - -c
            - date; echo Hello from the Kubernetes cluster
          restartPolicy: OnFailure
```

## Non-Compliant Code Examples{% #non-compliant-code-examples %}

```yaml
#this is a problematic code where the query should report a result(s)
apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: hello
spec:
  schedule: "*/1 * * * *"
  jobTemplate:
    spec:
      template:
        spec:
          containers:
          - name: hello
            image: busybox
            args:
            - /bin/sh
            - -c
            - date; echo Hello from the Kubernetes cluster
          restartPolicy: OnFailure
```