Is there a way to view the console outputs of a particular script that is running in the background on a machine?
There is now, via a brand new utility called pw
(Pipe Watch).
How it would go is like this. We redirect the output of the script to pw
, and put it into the background:
$ script.pm | pw &
[1] 1234
Now both the script and pw
are executing in the background. pw
is reading the output. It is aware that it is executing as a member of a background process group of a job control shell, and consequently refrains from trying to display anything on the terminal.
Then, at any time we feel like it, we do this:
$ fg
to bring the job to the foreground. Now pw
activates its interactive display, which is being refreshed with the script's output.
When we don't want to look at that any more, then we can use CtrlZ to instruct pw
to suspend itself, and then bg
command will resume the background execution.