no such file or directory error while executing yaml file as a cron job

0 votes

I was trying to execute a yaml file as cron job and got the following error:

container_linux.go:247: starting container process caused "exec: \"/home/ubuntu/exam.sh\": stat /home/ubuntu/exam.sh: no such file or directory"

This is my yaml file:

job2.yaml file 
apiVersion: batch/v1beta1
 kind: CronJob metadata:
   name: ghost
   labels:
    role: blog
 spec:   schedule: "*/1 * * * *"   jobTemplate:
    spec:
      template:
        spec:
          containers:
          - name: ghost
            image: ghost:0.11-alpine
            command: ["/home/ubuntu/exam.sh"]
          restartPolicy: OnFailure
Sep 18, 2018 in Kubernetes by lina
• 8,220 points
2,934 views

1 answer to this question.

0 votes

When you get errors like these, you first check if the job was executed a cron job, if the file exists and is executable

you can run it from kubectl run command:

kubectl run ghost --schedule="*/1 * * * *" --restart=OnFailure --image=ghost:0.11-alpine -- /bin/sh -c "your check script content" 
answered Sep 18, 2018 by Kalgi
• 52,360 points

Related Questions In Kubernetes

0 votes
3 answers

Using multiple commands in a kubernetes yaml file

Try something like this: containers: - name: ...READ MORE

answered Apr 23, 2019 in Kubernetes by lyza
48,938 views
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,789 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,616 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 6,107 views
+1 vote
4 answers

Execute shell script file using kubernetes as a cron job

use /bin/sh instead of /bin/bash This solved it ...READ MORE

answered May 7, 2019 in Kubernetes by Sid
17,049 views
0 votes
1 answer
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