2

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)

1 Answer 1

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!"]
4
  • 1
    Maybe you could add some text explaining your code?
    – JoSSte
    Commented Mar 7, 2023 at 5:24
  • I'm having trouble finding startTime in the CronJob API reference
    – recoup8063
    Commented Mar 7, 2023 at 6:10
  • 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
    Commented Mar 8, 2023 at 17:24
  • @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 kubernetes.io/docs/tasks/job/automated-tasks-with-cron-jobs Commented Apr 13, 2023 at 6:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.