<p>My requirement is that in my POD  multiple processes are running and I want to collect the metrices for all the processes i.e (CPU AND MEMORY and other details OF all Process). Now , I want to write the output of any command I run inside my pod to stout .</p>

beingumang
<blockquote>
<p>A container engine handles and redirects any output generated to a containerized application's <code>stdout</code> and <code>stderr</code> streams. For example, the Docker container engine redirects those two streams to a logging driver, which is configured in Kubernetes to write to a file in JSON format.</p>
</blockquote>
<p>Usually, it is PID1 process's stdout and stderr.<br />
So, try the following command inside a k8s Pod:</p>
<pre><code>$ cat /proc/meminfo &gt;&gt; /proc/1/fd/1
</code></pre>
<p>Then you will see the standard output in the pod's logs:</p>
<pre><code>$ kubectl logs yourPodName
...
MemTotal:       12807408 kB
MemFree:        10283624 kB
MemAvailable:   11461168 kB
Buffers:           50996 kB
Cached:          1345376 kB
...
</code></pre>
<p>To write <code>stdout</code> and <code>stderr</code> from the command, run it like this:</p>
<pre><code>$ cat /proc/meminfo 1&gt;&gt; /proc/1/fd/1 2&gt;&gt; /proc/1/fd/2
</code></pre>
