<pre class="lang-yml prettyprint-override"><code>apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: my-cronjob
spec:
  schedule: &quot;*/15 * * * *&quot;
  startTime: 2023-03-07T10:00:00Z
  jobTemplate:
    spec:
      activeDeadlineSeconds: 1800 #end time specification
      template:
        spec:
          containers:
          - name: my-container
            image: my-image
            command: [&quot;/bin/sh&quot;]
            args: [&quot;-c&quot;, &quot;echo Hello, World!&quot;]
</code></pre>

CC BY-SA 4.0
2023-03-07T05:24:51.383Z
Maybe you could add some text explaining your code?
JoSSte
CC BY-SA 4.0
2023-03-07T06:10:59.967Z
I'm having trouble finding `startTime` in the [CronJob API reference](https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/cron-job-v1/)
recoup8063
CC BY-SA 4.0
2023-03-08T17:24:39.203Z
The `startTime` field only appears in the CronJob status object which does not control the job but instead reports information on how the job ran.
recoup8063
CC BY-SA 4.0
2023-04-13T06:16:31.667Z
@NoahHuppert, Just to add to the above answers. You can use cronJob object and add custom time to tell cronjob when to launch job and your requisite pods, maybe more details you can find here https://kubernetes.io/docs/tasks/job/automated-tasks-with-cron-jobs/
Deepak Mourya
CC BY-SA 4.0
2023-03-07T05:07:19.093Z
2023-03-07T05:35:32.613Z
2023-03-07T05:35:32.613Z
Rahul Sherkar
<p>I am looking to see if there is a way of running a task on a repeat interval with an explicit start and end date.</p>
<p>In the ecosystem I have found that Cron Job task type lines up very well with a repeat task. However I've been having trouble finding a Cron Job scheduler that has a start and end date.</p>
<p>Most only allow a cron expression to provided to tune when a task is run. So far the only way I've found to enforce a start and end date is to make the logic of the task itself either exit early if before the start date or delete the job after the end date.</p>
<p>I was wondering if there were any schedulers that implemented start and end date behavior for recurring tasks.</p>
<p>(So far I've found the Kubernetes CronJob and Argo CronJob)</p>

<kubernetes><argocd>
Kubernetes repeating job with start and end date?
recoup8063
# Kubernetes repeating job with start and end date?

(Asked by: username_0 on 2023-03-06)

I am looking to see if there is a way of running a task on a repeat interval with an explicit start and end date.

In the ecosystem I have found that Cron Job task type lines up very well with a repeat task. However I've been having trouble finding a Cron Job scheduler that has a start and end date.

Most only allow a cron expression to provided to tune when a task is run. So far the only way I've found to enforce a start and end date is to make the logic of the task itself either exit early if before the start date or delete the job after the end date.

I was wondering if there were any schedulers that implemented start and end date behavior for recurring tasks.

(So far I've found the Kubernetes CronJob and Argo CronJob)

**Tags:** kubernetes, argocd


---

## 1 answers

### Answer by username_1 on 2023-03-07. Score: 0

apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: my-cronjob
spec:
  schedule: "*/15 * * * *"
  startTime: 2023-03-07T10:00:00Z
  jobTemplate:
    spec:
      activeDeadlineSeconds: 1800 #end time specification
      template:
        spec:
          containers:
          - name: my-container
            image: my-image
            command: ["/bin/sh"]
            args: ["-c", "echo Hello, World!"]

> **Comments:**
> **username_2**: Maybe you could add some text explaining your code?  
> **username_0**: I'm having trouble finding `startTime` in the [CronJob API reference](https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/cron-job-v1/)  
> **username_0**: The `startTime` field only appears in the CronJob status object which does not control the job but instead reports information on how the job ran.  
> **username_3**: @NoahHuppert, Just to add to the above answers. You can use cronJob object and add custom time to tell cronjob when to launch job and your requisite pods, maybe more details you can find here https://kubernetes.io/docs/tasks/job/automated-tasks-with-cron-jobs/  

---

