I have a C program which basically does the following:
(1) Prints a load of questions and scanf()'s responses
(2) Runs a simulation based upon the input, and prints out numbers on the screen (1, 2, 3, ...) using printf() to let me know how it's progressing.
What I often do is suspend the job after it's started running, and send it into the background: Ctrl-z, followed by typing bg. Of course, the printf() command continues to print the numbers, but if I wish I can log out of the shell and the program will keep going (useful since it's usually on a remote machine).
If I log out, of course, I can't keep track of the program's progress. So I was wondering: is there any Linux shell command that would enable me to select a running job and say, "OK, from now on any printing to the shell goes instead to this file"?
Basically I want the effect of,
./program > outputfile
... but to be able to apply the effect of > outputfile *after* the program has started, not from the beginning.
Is this possible?
Thanks in advance!
(1) Prints a load of questions and scanf()'s responses
(2) Runs a simulation based upon the input, and prints out numbers on the screen (1, 2, 3, ...) using printf() to let me know how it's progressing.
What I often do is suspend the job after it's started running, and send it into the background: Ctrl-z, followed by typing bg. Of course, the printf() command continues to print the numbers, but if I wish I can log out of the shell and the program will keep going (useful since it's usually on a remote machine).
If I log out, of course, I can't keep track of the program's progress. So I was wondering: is there any Linux shell command that would enable me to select a running job and say, "OK, from now on any printing to the shell goes instead to this file"?
Basically I want the effect of,
./program > outputfile
... but to be able to apply the effect of > outputfile *after* the program has started, not from the beginning.
Is this possible?
Thanks in advance!