Kubectl logs -f <pod> exit once the log print completes

9/8/2021

I need to include kubectl logs -f <pod> in a script, but since it's continuously running in my script it's not executing the next line of the script. Is there a way to exit the printing log once there are no more logs printing in the log file?

kubectl logs -f $POD $KUBECONF

while true;
  do
    kubectl exec $POD $KUBECONF --test -f /path/to/file
-- Eranda Kodagoda
kubectl
kubernetes

0 Answers