<p>Unable to remove files older than one day from the mounted volume. My yaml:</p>
<pre><code>apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: cfs-cleanup
spec:
  concurrencyPolicy: Forbid
  schedule: '0 4 * * *'
  successfulJobsHistoryLimit: 0
  failedJobsHistoryLimit: 10
  jobTemplate:
    spec:
      backoffLimit: 2
      activeDeadlineSeconds: 600
      template:
        metadata:
          annotations:
            sidecar.istio.io/inject: &quot;false&quot;
        spec:
          restartPolicy: Never
          containers:
            - name: cfs-cleanup
              image: alpine:3.13.2
              command: [&quot;find&quot;, &quot;/root/volumes/nginx-cache/cfs* -type f -mtime +1 -exec rm -f {} \;&quot;]
              volumeMounts:
                - name: cache
                  mountPath: /root/volumes/nginx-cache

          volumes:
            - name: cache
              hostPath:
                path: /root/volumes/nginx-cache
                type: DirectoryOrCreate
</code></pre>
<p>the container fails without an error and does nothing. Could it be that command gets executed before volume is mounted?</p>

<p>I'm just guessing, but in your command</p>
<pre><code>command: [&quot;find&quot;, &quot;/root/volumes/nginx-cache/cfs* -type f -mtime +1 -exec rm -f {} \;&quot;]
</code></pre>
<p>path <code>/root/volumes/nginx-cache/cfs*</code> won't get expanded.</p>
<p>To verify it, just try <code>command: [&quot;ls&quot;, &quot;/root/volumes/nginx-cache/cfs*&quot;]</code></p>
<p>You can try to wrap your command in <code>sh -c ...</code> like</p>
<pre><code>command: [&quot;sh&quot;, &quot;-c&quot;, &quot;find /root/volumes/nginx-cache/cfs* -type f -mtime +1 -exec rm -f {} \;&quot;]
</code></pre>
<p>Also, your command is possibly wrong altogether. You merged all arguments of <code>find</code> executable into single string (which shouldn't be problem when invoked via <code>sh -c ...</code>.</p>
