<p>I was using the following code to randomly kill processes inside the pods</p>

<pre><code>   : ${DELAY:=30}

if [ "$#" -ne 1 ]; then
    echo "One argument expected specifying the time in seconds to run"
else
 end=$((SECONDS+$1))
 while [ $SECONDS -lt $end ]; do
  kubectl \
    -o 'jsonpath={.items[*].metadata.name}' \
    get pods | \
      tr " " "\n" | \
      shuf | \
      head -n 1 |
      #xargs -t --no-run-if-empty \

      kubectl exec $(head -n 1) -- kill -9 9
  #if [ $((SECONDS+${DELAY})) -lt $end ];then            #break loop if (seconds completed + delay) is greater than time specified in argument
  # sleep "${DELAY}"                                     #sleep so that pod gets completely deleted and a terminating pod not selecte
  #else
  # break
  #fi
 done
fi
</code></pre>

<p>The script runs but no output is shown as in it goes into some infinite loop. Can someone help where I am going wrong?</p>

<p>Two things:
<code>-o 'jsonpath={.items[*].metadata.name}'</code> should go after <code>kubectl get pods</code>, otherwise kubectl will return help message.
Also, add -t to <code>kubectl exec</code> in order to see output from the container in your terminal.</p>
