2

At work, I fire-up a terminal and start executing some huge process(which may take couple of hours to complete) and leave office. When I reach home, I want to check what is happening to the process(not just checking if it is still running or not but to see the output as well). Is there a way to get connected to the same terminal and view the ongoing process.

Basework: I tried reading about this utility called screen. But it allows my remote machine to attach to the session that I started at work. It doesn't allow me to connect to that shell and see the progress.

ganessh
  • 131
  • Actually, in my understanding, shell are run by screen, so by reattaching to a screen session through another connection mean, you effectively get back the shell you were using. This requires to be run by this way : (work) ssh to the server, run screen, run command un shell ran by screen, detach from screens ession. (home) ssh to server, reattach to the screen session, and BAM you're at the same place. With suffisent tuning it even allows multi-users at the same time. – mveroone Aug 14 '13 at 12:07

2 Answers2

8

screen does exactly that. But you have to start the process in screen.

To create the session use

screen -S hugeprocess

To resume the session

If the screen is still running:

screen -x hugeprocess

If the screen has been detached:

screen -r hugeprocess

To detach from the session

CTRL + A+D

Enable screen log file

You may also want to use the -L parameter when you create the session to enable logging to ~/screenlog.0 which you can read using less -r screenlog.0

choroba
  • 19,261
  • 4
  • 49
  • 52
2

Try reptyr:

reptyr - Reparent a running program to a new terminal

slhck
  • 228,104
  • Can you give a more specific example of how this solves the problem? – slhck Aug 14 '13 at 10:40
  • 1
    (This assumes using ssh from the home machine into the work machine) Work machine: hugeprocess.sh Home machine: reptyr $(pgrep hugeprocess.sh) – justbrowsing Aug 14 '13 at 11:04