<p>I am trying to use this startup probe</p>
<pre><code>          startupProbe:
            exec:
              command:
                - &gt;-
                  test $(java -cp /the/path/to/the/app.jar app.Controller port=4990 cmd=&quot;v&quot; | grep -E 'r5|v5' | wc -l) -eq 2 &amp;&amp; echo $? || echo $?
            initialDelaySeconds: 5 #How many seconds to wait after the container has started
            timeoutSeconds: 1 #Timeout of the probe
            successThreshold: 1 #Threshold needed to mark the container healthy
            periodSeconds   : 10 #Wait time between probe executions
            failureThreshold: 110 #Threshold needed to mark the container unhealthy.
</code></pre>
<p>It is a java app that can take a long time (~15 mins) to load some components. It is a legacy app, not much I can do about it.</p>
<p>I am greping the response, trying to get two lines as a result, and then returning 0 or 1 as exit codes for the probe to decide.</p>
<p>I get his error though</p>
<pre><code>Startup probe errored: rpc error: code = Unknown desc = failed to exec in container: failed to start exec &quot;8ad860ffc7a87e95fb65e37dc14945c04fa205f9a524c7f7f08f9d6ef7d75&quot;: OCI runtime exec failed: exec failed: container_linux.go:380: starting container process caused: exec: &quot;test $(java -cp /the/path/to/the/app.jar app.Controller port=4990 cmd=\&quot;v\&quot; | grep -E 'r5|v5' | wc -l) -eq 2 &amp;&amp; echo $? || echo $?&quot;: stat test $(java -cp /the/path/to/the/app.jar app.Controller port=4990 cmd=&quot;v&quot; | grep -E 'r5|v5' | wc -l) -eq 2 &amp;&amp; echo $? || echo $?: no such file or directory: unknown
</code></pre>
<p>If I dont use the <code>&amp;&amp; echo $? || echo $?</code> part, the probe throws error that the exit code is <code>2</code> and not <code>1</code>.</p>
<p>What is going on ??</p>

Kostas Demiris
<p>You need to start a shell to run your script:</p>
<pre><code>startupProbe:
  exec:
    command:
    - sh
    - -c
    - &gt;-
      ...
</code></pre>
