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
3,399 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,350 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
49,932 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,350 points
3,136 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
15,577 views
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
4,062 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,778 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