More adventures in the shell
Friday, August 8, 2008 - By Steve Maresca
Forced backgrounding of processes
The following dissociates stdout/stderr/stdin (saves output in nohup.out) and removes controlling terminal so that you can close the terminal or log out while still permitting the program to execute.
nohup /path/to/some/command/that/isnt/a/daemon & disown %-
This can be useful for long operations that do not require interaction (otherwise you'd just use the screen utility of course).
For similar goals where this fails, justin has some code to solve the problem. Perhaps he will post it.
Shared terminal session, the ghetto method (readonly)
The following permits a user on terminal A to show another user on terminal B what transpires (in real time) during a terminal session. A fifo is created as a first step and then script is run with its output directed to this fifo -- the script command will appear to hang, but when the user on terminalB uses cat upon the fifo, script will exit succesfully. This is somewhat useful - it alerts the user on termA that the other user is ready.
terminalA$ mkfifo /tmp/outNow, you could use script to record a session and distribute the result afterward, but sometimes observing as things happen is useful. For a more flexible mechanism to accomplish the same, the GNU screen utility has shared session ability - including permissions with respect to reading/writing.
terminalA$ script -f /tmp/outterminalB$ cat /tmp/out