<p>I'm trying to use pod's lifecycle event. Problem is that command from <code>preStop</code> doesn't run at all. Is there any way to monitor if it was started? Log of the container is empty. </p>

<pre><code>      lifecycle:
        preStop:
          exec:
            command: [ "/bin/sh", "-c", "/clean.sh" ]
</code></pre>

<p>I was looking for something, so I added some logging that help to see the logs of the script in the pod's stdout/stderr logs.</p>
<p>so for me, this approach help me</p>
<ul>
<li>To write logs to the centralized logging system (help me to check logs in datadog)</li>
<li>Verify the script is executed properly</li>
</ul>
<pre><code>          lifecycle:
            preStop:
              exec:
                command: [&quot;/bin/sh&quot;, &quot;-c&quot;, &quot;/clean.sh &gt; /proc/1/fd/1&quot;]          

</code></pre>
<p>and was able to verify the logs</p>
<pre><code>kubectl get pods

kubectl logs -f my_stohook_pod

</code></pre>
<p><code>/proc/PID/fd/1</code> will help us to redirect script logs stdout/stderr of the container main process.</p>
