I'm trying to start port-forwarding in the background while suppressing all output. Here is what I've tried:
kubectl port-forward pod-name 1234:1234 > /dev/null 2>&1 &
Yet when I initiate connections, I still see messages like this:
Handling connection for 1234
As I understand it, both standard output and error should be directed to /dev/null.
My belief seems to be confirmed by the silence of this script:
echo "hi" > /dev/null 2>&1 & # test stdout silence
>&2 echo "hi" > /dev/null 2>&1 & # test stderr silence
(Note: I had to run these in a script rather than a shell, to avoid my shell's default output about subshells.)
I don't know what else I can do to suppress the kubectl port-forward
output. What am I missing?
Here is what worked in my case (after command execution output is completely silent):
kubectl port-forward pod-name 1234:1234 2>&1 >/dev/null &
which says send stderr
output to the same place where stdout
output which is /dev/null
Tested for:
Ubuntu 18.04
Kernel 5.4.0-70-generic
GNU bash, version 4.4.20(1)-release (x86_64-pc-linux-gnu)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With