"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,110 points
91 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
• 40,440 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 in Kubernetes by lyza
4,807 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
• 40,440 points
106 views
0 votes
1 answer

Run a cron job once in N hours

If you want your cron job to ...READ MORE

answered Sep 18, 2018 in Kubernetes by Kalgi
• 40,440 points
32 views
0 votes
1 answer
0 votes
3 answers

Error while joining cluster with node

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

answered Jan 17 in Others by anonymous
2,110 views
+3 votes
1 answer
+1 vote
4 answers
0 votes
1 answer