<p>Hi I'm new with Kubernetes. I'm trying to run wget command in cronjob.yml file to get data from url each day. For now I'm testing it and pass schedule as 1min. I also add some echo command just to get some response from that job. Below is my yml file. I'm changing directory to folder where I want to save data and passing url with site from which I'm taking it. I tried url in terminal with <code>wget url</code> and it works and download json file hidden in url.</p>
<pre><code>apiVersion: batch/v1
kind: CronJob
metadata:
  name: reference
spec:
  schedule: &quot;*/1 * * * *&quot;
  jobTemplate:
    spec:
      template:
        spec:
          containers:
          - name: reference
            image: busybox
            imagePullPolicy: IfNotPresent
            command:
            - /bin/sh
            - -c
            - date; echo Hello from the Kubernetes cluster
            - cd /mnt/c/Users/path_to_folder
            - wget {url}
          restartPolicy: OnFailure
</code></pre>
<p>When I create job and watch the pod logs nothing happen with url, I don't get any response.
Commands I run are:</p>
<ul>
<li><code>kubectl create -f cronjob.yml</code></li>
<li><code>kubectl get pods</code></li>
</ul>
<p><a href="https://i.stack.imgur.com/3fc1b.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3fc1b.png" alt="kubectl get pods info" /></a></p>
<ul>
<li><code>kubectl logs &lt;pod_name&gt;</code></li>
</ul>
<p><a href="https://i.stack.imgur.com/DIGVH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DIGVH.png" alt="enter image description here" /></a></p>
<p>In return I just get only command with date (img above)</p>
<p>When I leave just command with wget, nothing happen. In pods I can see in STATUS CrashLoopBackOff. So the command has problem to run.</p>
<pre><code>command:
                - cd /mnt/c/Users/path_to_folder
                - wget {url}
</code></pre>
<p><a href="https://i.stack.imgur.com/XdNF3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XdNF3.png" alt="kubectl get pods info" /></a></p>
<p>How does wget command in cronjob.yml should look like?</p>

Dysio
<p>The <code>command</code> in kubernetes is docker <a href="https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#notes" rel="nofollow noreferrer">equivalent</a> to <code>entrypoint</code> in docker. For any container, there should be <a href="https://docs.docker.com/engine/reference/builder/#entrypoint" rel="nofollow noreferrer">only one</a> process as entry point. Either the default entry point in the image or supplied via <code>command</code>.</p>
<p>Here you are using <code>/bin/sh</code> as a single process and everything else as it's argument. The way you were executing <code>/bin/sh -c</code> , it means providing <code>date; echo Hello from the Kubernetes cluster</code> as input command. NOT the <code>cd</code> and <code>wget</code> commands. Change your manifest to the following to feed everything as one block to the <code>/bin/sh</code>. Note that, all the commands is fit as 1 argument.</p>
<pre><code>apiVersion: batch/v1
kind: CronJob
metadata:
  name: reference
spec:
  schedule: &quot;*/1 * * * *&quot;
  jobTemplate:
    spec:
      template:
        spec:
          containers:
          - name: reference
            image: busybox
            imagePullPolicy: IfNotPresent
            command:
            - /bin/sh
            - -c
            - date; echo Hello from the Kubernetes cluster; cd /mnt/c/Users/path_to_folder;wget {url}
          restartPolicy: OnFailure
</code></pre>
<p>To illustrate the problem, check the following examples. Note that only 1st argument is executed.</p>
<pre><code>/bin/sh -c date
Tue 24 Aug 2021 12:28:30 PM CDT
/bin/sh -c echo hi

/bin/sh -c 'echo hi'
hi
/bin/sh -c 'echo hi &amp;&amp; date'
hi
Tue 24 Aug 2021 12:28:45 PM CDT
/bin/sh -c 'echo hi' date #&lt;-----your case is similar to this, no date printed.
hi
</code></pre>
<blockquote>
<pre><code>       -c               Read commands from the command_string operand instead of from the standard input.  Special parameter 0
                        will be set from the command_name operand and the positional parameters ($1, $2, etc.)  set from the re‐
                        maining argument operands.
</code></pre>
</blockquote>
