ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Unsolved Save shell session to disk?

    IT Discussion
    linux
    5
    14
    778
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • 1
      1337
      last edited by 1337

      Is there a way you can save a shell session to disk for later recall?

      It would save your current directory, environment variables, screen buffer etc.

      So if you were working on something, you could resume that later, even if the system had been rebooted.

      JaredBuschJ 1 Reply Last reply Reply Quote 2
      • stacksofplatesS
        stacksofplates
        last edited by

        tmux is really the closest thing I know of, but it won't save to disk or survive a reboot.

        1 1 Reply Last reply Reply Quote 2
        • ITivan80I
          ITivan80
          last edited by

          You might want to use Putty as a choice.

          1 scottalanmillerS 2 Replies Last reply Reply Quote 0
          • 1
            1337 @stacksofplates
            last edited by

            @stacksofplates said in Save shell session to disk?:

            tmux is really the closest thing I know of, but it won't save to disk or survive a reboot.

            Yes, I usually use screen but it won't save or survive a reboot either.

            1 Reply Last reply Reply Quote 0
            • 1
              1337 @ITivan80
              last edited by 1337

              @ITivan80 said in Save shell session to disk?:

              You might want to use Putty as a choice.

              Thanks, I do sometimes on Windows but the problem I have isn't saving ssh sessions on the client, such as login credentials, which putty does.

              The problem is that I want to save the unix shell session on the server. Screen buffers, environment variables, history, current directory etc. So I can resume my work later from the same point.

              scottalanmillerS 1 Reply Last reply Reply Quote 0
              • JaredBuschJ
                JaredBusch @1337
                last edited by

                @Pete-S said in Save shell session to disk?:

                Is there a way you can save a shell session to disk for later recall?
                It would save your current directory, environment variables, screen buffer etc.

                I've never heard of anything like this. I have also never looked, but if it exists, it is not commonly known.

                1 Reply Last reply Reply Quote 1
                • scottalanmillerS
                  scottalanmiller @ITivan80
                  last edited by

                  @ITivan80 said in Save shell session to disk?:

                  You might want to use Putty as a choice.

                  PuTTY is a terminal app, but isn't aware of what is happening inside of it. So doesn't manage any of these features, and it isn't needed. Every OS now has good, native terminals so the era of PuTTY is long over. It's a good tool if Windows didnt have a good terminal natively, but it does.

                  1 Reply Last reply Reply Quote 0
                  • scottalanmillerS
                    scottalanmiller @1337
                    last edited by

                    @Pete-S said in Save shell session to disk?:

                    The problem is that I want to save the unix shell session on the server. Screen buffers, environment variables, history, current directory etc. So I can resume my work later from the same point.

                    So there are two ways to do this...

                    1. Work in an idempotent way and be stateless. Basically doing functional programming. Huge pain and no one does this. But this is how this would be handled.

                    2. Live without the ability to survive a SERVER side reboot, and just use screen and it is designed to do this (except for the reboot thing.) You disconnect your session and can pick it back up in situ from anywhere.

                    JaredBuschJ 1 2 Replies Last reply Reply Quote 1
                    • scottalanmillerS
                      scottalanmiller
                      last edited by

                      But nothing AFAIK will flush a state to disk to save for later. That would be effectively impossible as nothing can control the state in such a way as to be able to reliably do that. Because of the way that it affects other things, saving the system state isn't viable at the user level.

                      1 Reply Last reply Reply Quote 0
                      • JaredBuschJ
                        JaredBusch @scottalanmiller
                        last edited by

                        @scottalanmiller said in Save shell session to disk?:

                        Live without the ability to survive a SERVER side reboot, and just use screen and it is designed to do this (except for the reboot thing.) You disconnect your session and can pick it back up in situ from anywhere.

                        This is what I don on the rare occasion that i know ahead of time that I need to preserve an environment to come back to later.

                        It almost never happens that I know ahead of time, and I do not like to launch screen for no reason.

                        scottalanmillerS 1 Reply Last reply Reply Quote 1
                        • scottalanmillerS
                          scottalanmiller @JaredBusch
                          last edited by

                          @JaredBusch said in Save shell session to disk?:

                          It almost never happens that I know ahead of time, and I do not like to launch screen for no reason.

                          That totally gets me, too.

                          1 1 Reply Last reply Reply Quote 0
                          • 1
                            1337 @scottalanmiller
                            last edited by 1337

                            @scottalanmiller said in Save shell session to disk?:

                            @JaredBusch said in Save shell session to disk?:

                            It almost never happens that I know ahead of time, and I do not like to launch screen for no reason.

                            That totally gets me, too.

                            That's why you should launch ssh like this:
                            ssh [email protected] -t screen -RR

                            If you don't have a session going it will create one.
                            If you had a session going but it was interrupted, it will reconnect to it automatically.

                            And it's completely transparent from the users point of view. No need to run any screen commands or keyboard shortcuts.

                            Especially good in these situations:

                            • a laptop that you close the lid on
                            • flaky internet connection
                            • desktop PC in a country with unreliable power grid
                            • when running a process that takes a long time, like copying files
                            JaredBuschJ 1 Reply Last reply Reply Quote 1
                            • 1
                              1337 @scottalanmiller
                              last edited by

                              @scottalanmiller said in Save shell session to disk?:

                              @Pete-S said in Save shell session to disk?:

                              The problem is that I want to save the unix shell session on the server. Screen buffers, environment variables, history, current directory etc. So I can resume my work later from the same point.

                              So there are two ways to do this...

                              1. Work in an idempotent way and be stateless. Basically doing functional programming. Huge pain and no one does this. But this is how this would be handled.

                              2. Live without the ability to survive a SERVER side reboot, and just use screen and it is designed to do this (except for the reboot thing.) You disconnect your session and can pick it back up in situ from anywhere.

                              Number 2 is what I do today.

                              1 Reply Last reply Reply Quote 0
                              • JaredBuschJ
                                JaredBusch @1337
                                last edited by

                                @Pete-S said in Save shell session to disk?:

                                That's why you should launch ssh like this:
                                ssh [email protected] -t screen -RR
                                If you don't have a session going it will create one.
                                If you had a session going but it was interrupted, it will reconnect to it automatically.

                                @JaredBusch said in Save shell session to disk?:

                                I do not like to launch screen for no reason.

                                1 Reply Last reply Reply Quote 0
                                • 1 / 1
                                • First post
                                  Last post