By default, if you execute a background process ended with &
, like ./test &
, the output will be printed in the current terminal.
How can I redirect the output to a pager like less
when it finishes running other than output directly?
Redirect the background process output to a pager `less` after finish running not to default terminal
background-processless
Best Answer
Simplest way: Redirect the output to a file. When the command has finished executing, view the file in
less
../test.sh >test.out &
less test.out
This is under some circumstances also useful even if the command is not run in the background, for example if compiling a large project:
or
Then you can, in your own time go through the output to look for errors etc. (or send it to the developer as part of a bug report), without having to scroll up and down in your terminal.