<p>I am trying to create a cronjob that runs the command <strong>date</strong> in a single busybox container. The command should run every minute and must complete within 17 seconds or be terminated by Kubernetes. The cronjob name and container name should both be hello.</p>
<pre><code>apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: hello
spec:
  jobTemplate:
    metadata:
      name: hello
    spec:
      completions: 1
      activeDeadlineSeconds: 17
      template:
        metadata:
          creationTimestamp: null
        spec:
          containers:
          - image: busybox
            name: hello
            command: [&quot;/bin/sh&quot;,&quot;-c&quot;,&quot;date&quot;]
            resources: {}
          restartPolicy: OnFailure
  schedule: '*/1 * * * *'
status: {}
</code></pre>
<p>I want to verify that the job executed successfully at least once.
I tried it using the command <strong>k get cronjob -w</strong> which gives me this result.</p>
<p><a href="https://i.stack.imgur.com/cZJp3.png" rel="noreferrer"><img src="https://i.stack.imgur.com/cZJp3.png" alt="enter image description here" /></a></p>
<p>Is there another way to verify that the job executes successfully? Is it a good way to add a command <strong>date</strong> to the container?</p>

O.Man
<p><code>CronJob</code> internally creates <code>Job</code> which internally creates <code>Pod</code>. Watch for the job that gets created by the <code>CronJob</code></p>
<pre><code>kubectl get jobs --watch
</code></pre>
<p>The output is similar to this:</p>
<pre><code>NAME               COMPLETIONS   DURATION   AGE
hello-4111706356   0/1                      0s
hello-4111706356   0/1           0s         0s
hello-4111706356   1/1           5s         5s
</code></pre>
<p>And you can see the number of <code>COMPLETIONS</code></p>
<pre><code>#Replace &quot;hello-4111706356&quot; with the job name in your system

pods=$(kubectl get pods --selector=job-name=hello-4111706356 --output=jsonpath={.items[*].metadata.name})
</code></pre>
<p>Check the pod logs</p>
<pre><code>kubectl logs $pods
</code></pre>
