Answers: <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>
  
Answers: CC BY-SA 4.0
Answers: 2023-03-07T05:24:51.383Z
Answers: Maybe you could add some text explaining your code?
Answers: JoSSte
Answers: CC BY-SA 4.0
Answers: 2023-03-07T06:10:59.967Z
Answers: I'm having trouble finding `startTime` in the [CronJob API reference](https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/cron-job-v1/)
Answers: recoup8063
Answers: CC BY-SA 4.0
Answers: 2023-03-08T17:24:39.203Z
Answers: 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.
Answers: recoup8063
Answers: CC BY-SA 4.0
Answers: 2023-04-13T06:16:31.667Z
Answers: @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/
Answers: Deepak Mourya
Answers: CC BY-SA 4.0
Answers: 2023-03-07T05:07:19.093Z
Answers: 2023-03-07T05:35:32.613Z
Answers: 2023-03-07T05:35:32.613Z
Answers: Rahul Sherkar
Body: <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>
  
Tags: <kubernetes><argocd>
Title: Kubernetes repeating job with start and end date?
UserDisplayName: recoup8063
ThreadText: # 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
  
  ```yml
  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/  
  
  ---
  
  