2

I'm sure this is a very basic question. I assume tmux could facilitate this, but I'm not sure of the exact steps.

My use-case is:

I'm sitting at my desktop and I ssh into a server. I start a long-running process. The process continues running on the server while I do other things (but I do not necessarily detach from the server at this time).

Now I'm on my laptop. (Say I went to lunch.) I need to ssh into that same server, see the same console output I would see on my desktop if I were there, and send some keystrokes to that same still-running application. I need to interact with it exactly as if I were still at my desktop ssh session. When finished, I will detach from this session and allow the application to continue running on the server.

Later, I will check on it from my desktop at work. At the end of the work day I will detach from it and go home. (Now no sessions at attached to the process on the server.) At home I will connect to the server and attach to the same still-running application, see what is on the screen and possibly send it some commands.

tmux seems to have such a focus on terminal multiplexing that my use-case is not explained in the answers or tutorials I have found so far. My use-case appears to be almost the opposite. I do not need to sit at one screen and connect to multiple servers. I will be working on one server, but connecting to it from multiple different computers, sometimes having multiple connections open at once, sometimes having no connections at all, and my focus is interacting with one long-running application on the server.

What are the steps to connect to the server and start my console application, then connect to that same application and see the same console output from multiple other computers?

Also, does tmux have to be installed on clients and the server?

MountainX
  • 17,948
  • @muru the accepted answer there does not seem to address my use-case (especially for reconnecting or for viewing same console output from different computers). Also, from the little I know, tmux seems to be the most popular tool but it receives little attention at that question. Finally, I am requesting a few simple steps to accomplish a specific task which is different from that question. – MountainX Oct 01 '18 at 03:07
  • XY problem. Note both OP there and you want to keep some program running and then later check the progress. The second answer there has "a few simple steps" to accomplish this specific task with screen. And another answer covers the difference for tmux. (The steps are same for screen and tmux, only the specific options and keybindings differ) – muru Oct 01 '18 at 03:10
  • @muru I posted a simple answer. It wasn't as hard as I anticipated. If you still think this question doesn't belong, let me know and I'll delete it. – MountainX Oct 01 '18 at 03:22
  • 2
    How unsurprisingly similar to https://unix.stackexchange.com/a/480/70524. – muru Oct 01 '18 at 03:23
  • 1
    tmux covered by https://unix.stackexchange.com/a/242832/70524 – muru Oct 01 '18 at 04:43
  • screen for text mode, NX (No Machine) for graphic modes... – Rui F Ribeiro Oct 01 '18 at 10:40

1 Answers1

3

I decided to use tmux. I do not believe nohup long-running-process & meets my requirements. I gave tmux a try and it does work as desired. It appears that in my use-case tmux is only required to be installed on the server.

  1. I'm sitting at my desktop at work:

    $ ssh my_server
    $ tmux new-session -s my_session_name
    $ application_name #to start the long-running application and view its output on the console

  2. Now I'm on my laptop. (Say I went to lunch.):

    $ ssh my_server
    $ tmux attach-session my_session_name
    view console output of same application_name
    issue keystrokes as required
    ctrl-b d # to detach tmux session
    $ exit # to disconnect ssh session

  3. At the end of the work day I will detach from it and go home:

    ctrl-b d
    $ exit

  4. At home I will connect to the server:

    $ ssh my_server
    $ tmux attach-session my_session_name
    view console output of application_name
    issue keystrokes as required
    ctrl-b d
    $ exit

Next morning at work, reconnect the same way.

MountainX
  • 17,948