<p>I have a process running inside an Ubuntu container and would like to redeploy the container if the process gets killed. I added the following liveness probe in container spec </p>

<pre><code>  livenessProbe:
    exec:
     command:
     - ps -ef | grep my_process_name
    initialDelaySeconds: 120
    periodSeconds: 30
</code></pre>

<p>However this doesnt work. When I do a <code>kubectl describe pods &lt;pod_id&gt;</code> I get the following event. </p>

<pre><code>  1h    6m      20      {kubelet k8s-agent-71e8d996-0}        spec.containers{my_process_name}       Warning Unhealthy       Liveness       probe failed: rpc error: code = 13 desc = invalid header field value "oci runtime error: exec failed: container_linux.go:247: starting container process caused \"exec: \\\"ps -ef | grep my_process_name\\\": executable file not found in $PATH\"\n"
</code></pre>

<p>And it keeps redeploying the container. If I bash into the container and do a 'ps -ef' it works but this doesnt
Whats a good way to use the liveness probe to check if a process is running or not ? Thanks. </p>

user3499908
<p>Make sure <code>ps</code> is installed. If it does not run: <code>apt-get update &amp;&amp; apt-get install procps</code></p>
<p>For the ease of copy-pasting OP's comment under the question :-).</p>
<p>Below, <code>worker.py</code> is the process that needs to be checked:</p>
<pre><code>livenessProbe:
  exec:
    command:
    - /bin/bash
    - -c
    - ps -ef | grep worker.py | grep -v grep
  initialDelaySeconds: 10
  periodSeconds: 10
</code></pre>
