Skip to main content
edited tags
Link
Jeff Schaller
  • 68.8k
  • 35
  • 122
  • 265
Source Link
xmllmx
  • 1.9k
  • 5
  • 22
  • 30

Why doesn't I/O redirection work when killing background jobs?

[~]$ kill %123

bash: kill: %123: no such job

[~]$ kill %123 2>&1 > /dev/null

bash: kill: %123: no such job

I want to disable all output during killing background jobs.

The first output is expected. However, the second output is not.

As showed in the command line, I add 2>&1 to redirect stderr to stdout, and use > /dev/null to redirect all output to null device. But the output is still showed on the terminal.

Any explanations?

Thanks in advance.

Updated Information:

The following command works as expected:

kill %123 > /dev/null 2>&1