How to run 2 cron jobs scheduled for every month

0 votes

I want to run two cron jobs to be scheduled every month. The cron jobs are in a JS file. How do I create a job that runs those JS files in the pod running that service every month using Kubernetes ? 

Sep 27, 2018 in Kubernetes by Hannah
• 18,570 points
975 views

1 answer to this question.

0 votes

Unfortunately, you cannot run the CronJob inside a container of your application.

The only thing you can do is create a container which will contain your cronjob and necessary environment for running it and schedule to run that pod by a CronJob.

Here is an example of the configuration:

apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: hello
spec:
  schedule: "*/1 * * * *" # syntax is a same as in system cron jobs
  jobTemplate:
    spec:
      template:
        spec:
          containers:
          - name: hello
            image: image_with_cronjob_code # here is an image with your cronjob
            args:
            - /bin/sh
            - -c
            - date; echo Hello from the Kubernetes cluster
          restartPolicy: OnFailure
answered Sep 27, 2018 by Kalgi
• 52,360 points

Related Questions In Kubernetes

0 votes
1 answer

How to fail a (cron) job after a certain number of retries?

You're trying to set 3 asbackoffLimit of your Job. ...READ MORE

answered Sep 17, 2018 in Kubernetes by Kalgi
• 52,360 points
2,761 views
0 votes
1 answer

Unable to schedule jobs every couple of days

Yes that is a very weird problem ...READ MORE

answered Sep 19, 2018 in Kubernetes by Kalgi
• 52,360 points
522 views
0 votes
1 answer

Can I configure my kubernetes job to run for a specified time?

When we create a job spec, we ...READ MORE

answered Jul 17, 2019 in Kubernetes by Sirajul
• 59,230 points
932 views
0 votes
1 answer

How to configure a default imagePullSecret for any deployment?

Hey @Sam, you can attach an image ...READ MORE

answered Jul 18, 2019 in Kubernetes by Sirajul
• 59,230 points
1,712 views
+1 vote
1 answer
0 votes
3 answers

Error while joining cluster with node

Hi Kalgi after following above steps it ...READ MORE

answered Jan 17, 2019 in Others by anonymous
14,524 views
+4 votes
1 answer

Installing Web UI (Dashboard):kubernetes-dashboard on main Ubuntu 16.04.6 LTS (Xenial Xerus) server

Follow these steps: $ kubeadm reset $ kubeadm init ...READ MORE

answered Apr 12, 2019 in Kubernetes by Kalgi
• 52,360 points

reshown Apr 12, 2019 by Kalgi 5,977 views
0 votes
1 answer

Why do jobs have to be idempotent - kubernetes cron jobs

To understand why this happens lets for ...READ MORE

answered Sep 17, 2018 in Kubernetes by Kalgi
• 52,360 points
2,389 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP