<p>Currently I have a Kubernetes pod that is running a cron job. The cron job writes to a log file at <code>/var/log/cronlog</code>. However, when I type <code>kubectl log my-pod-name</code>, the contents of <code>/var/log/cronlog</code> is not included.</p>

<p>How do I make it so that the contents of <code>/var/log/cronlog</code> is included with the output of <code>kubectl log my-pod-name</code>?</p>

<p>First why you don't create <a href="https://kubernetes.io/docs/concepts/workloads/controllers/jobs-run-to-completion/" rel="nofollow noreferrer">Jobs</a> using a <a href="https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/" rel="nofollow noreferrer">CronJob Controller</a>?</p>

<p>I think you should take advantage of using Kubernetes and make use of Jobs if they are supposed to run instead of plain cronjob. This will consume less resources and you will quickly check if cronjob failed.</p>

<p>Also as it was already mentioned in previous answers, you need to send messages/logs to stdout </p>

<p>Here is an example of a CronJob that does send <code>date</code> and prints <code>Hello from the Kubernetes cluster</code> to stdout, and logs can be accessed by <code>kubectl logs job/&lt;JOB_NAME&gt;</code></p>

<pre><code>apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: hello
  namespace: default
spec:
  schedule: "* * * * *" # run every minute
  startingDeadlineSeconds: 10 # if a job hasn't starting in this many seconds, skip
  concurrencyPolicy: Forbid # either allow|forbid|replace
  successfulJobsHistoryLimit: 3 # how many completed jobs should be
  jobTemplate:
    spec:
      template:
        spec:
          containers:
            - name: hello
              image: busybox
              args:
                - /bin/sh
                - -c
                - date; echo Hello from the Kubernetes cluster
          restartPolicy: OnFailure
</code></pre>

<p>I hope this provide a bit of overview for You.</p>
