<p>when I run the cronjob into Kubernetes, that time cron gives me to success the cron but not getting the desired result</p>
<pre><code>apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: {{ $.Values.appName }}
  namespace: {{ $.Values.appName }}
spec:
  schedule: &quot;* * * * *&quot;
  concurrencyPolicy: Forbid
  jobTemplate:
    spec:
      template:
        spec:
          containers:
            - name: test
              image: image
              command: [&quot;/bin/bash&quot;] 
              args: [ &quot;test.sh&quot; ]
          restartPolicy: OnFailure
</code></pre>
<p>also, I am sharing test.sh</p>
<pre><code>#!/bin/sh
rm -rf /tmp/*.*
echo &quot;remove done&quot;
</code></pre>
<p>cronjob running successfully but
when I checked the container the file is not getting deleted  into <strong>/tmp</strong> directory</p>

<p>Cronjob run in one specific container, if you want to remove the file or directory from another container it won't work.</p>
<p>If your main container running under deployment while when your job or cronjob gets triggered it create a <strong>new container</strong> <strong>(POD)</strong> which has a separate file system and mount option.</p>
<p>if you want to achieve this scenario you have to use the <strong>PVC</strong> with <strong>ReadWriteMany</strong> where <strong>multiple containers</strong> (POD) can connect with your <strong>single PVC</strong> and share the file system.</p>
<p>In this way then your <strong>cronjob container</strong> (POD) get started with the existing PVC file system and you can remove the directory using job or cronjobs.</p>
<p>mount the same <strong>PVC</strong> to the cronjob container and the main container and it will work.</p>
