viewing bash output from another shell retrospectively












3















I have python process running from a shell on a Linux. At the moment I don't have physical access to this machine and only can connect through ssh.

I know that the python process stopped and I suspect there is an error trace in this shell.

I can get pid of the shell but I can't find a way to display what is in this shell. Basically, I am looking to find a way to read what is already there and do not lose this output or close the shell.
What would be the Linux tool to have a second view of what is going on in already running shell?










share|improve this question























  • Has the shell been run through a terminal (ie did you launch it from a GUI)?

    – davidgo
    Jan 23 at 18:39











  • You could install a VNC server and then connect to it, to view the terminal shell? If you used a tty then I'm not sure how to view it remotely.

    – QuickishFM
    Jan 23 at 18:43











  • @davidgo the shell was started when on gnome and it is tty. I can't install VNC on this machine

    – tomasz74
    Jan 23 at 18:46











  • I would recommend going forward to use: linux.die.net/man/1/screen

    – kylie.a
    Jan 24 at 1:42
















3















I have python process running from a shell on a Linux. At the moment I don't have physical access to this machine and only can connect through ssh.

I know that the python process stopped and I suspect there is an error trace in this shell.

I can get pid of the shell but I can't find a way to display what is in this shell. Basically, I am looking to find a way to read what is already there and do not lose this output or close the shell.
What would be the Linux tool to have a second view of what is going on in already running shell?










share|improve this question























  • Has the shell been run through a terminal (ie did you launch it from a GUI)?

    – davidgo
    Jan 23 at 18:39











  • You could install a VNC server and then connect to it, to view the terminal shell? If you used a tty then I'm not sure how to view it remotely.

    – QuickishFM
    Jan 23 at 18:43











  • @davidgo the shell was started when on gnome and it is tty. I can't install VNC on this machine

    – tomasz74
    Jan 23 at 18:46











  • I would recommend going forward to use: linux.die.net/man/1/screen

    – kylie.a
    Jan 24 at 1:42














3












3








3


2






I have python process running from a shell on a Linux. At the moment I don't have physical access to this machine and only can connect through ssh.

I know that the python process stopped and I suspect there is an error trace in this shell.

I can get pid of the shell but I can't find a way to display what is in this shell. Basically, I am looking to find a way to read what is already there and do not lose this output or close the shell.
What would be the Linux tool to have a second view of what is going on in already running shell?










share|improve this question














I have python process running from a shell on a Linux. At the moment I don't have physical access to this machine and only can connect through ssh.

I know that the python process stopped and I suspect there is an error trace in this shell.

I can get pid of the shell but I can't find a way to display what is in this shell. Basically, I am looking to find a way to read what is already there and do not lose this output or close the shell.
What would be the Linux tool to have a second view of what is going on in already running shell?







linux bash shell






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jan 23 at 18:25









tomasz74tomasz74

132147




132147













  • Has the shell been run through a terminal (ie did you launch it from a GUI)?

    – davidgo
    Jan 23 at 18:39











  • You could install a VNC server and then connect to it, to view the terminal shell? If you used a tty then I'm not sure how to view it remotely.

    – QuickishFM
    Jan 23 at 18:43











  • @davidgo the shell was started when on gnome and it is tty. I can't install VNC on this machine

    – tomasz74
    Jan 23 at 18:46











  • I would recommend going forward to use: linux.die.net/man/1/screen

    – kylie.a
    Jan 24 at 1:42



















  • Has the shell been run through a terminal (ie did you launch it from a GUI)?

    – davidgo
    Jan 23 at 18:39











  • You could install a VNC server and then connect to it, to view the terminal shell? If you used a tty then I'm not sure how to view it remotely.

    – QuickishFM
    Jan 23 at 18:43











  • @davidgo the shell was started when on gnome and it is tty. I can't install VNC on this machine

    – tomasz74
    Jan 23 at 18:46











  • I would recommend going forward to use: linux.die.net/man/1/screen

    – kylie.a
    Jan 24 at 1:42

















Has the shell been run through a terminal (ie did you launch it from a GUI)?

– davidgo
Jan 23 at 18:39





Has the shell been run through a terminal (ie did you launch it from a GUI)?

– davidgo
Jan 23 at 18:39













You could install a VNC server and then connect to it, to view the terminal shell? If you used a tty then I'm not sure how to view it remotely.

– QuickishFM
Jan 23 at 18:43





You could install a VNC server and then connect to it, to view the terminal shell? If you used a tty then I'm not sure how to view it remotely.

– QuickishFM
Jan 23 at 18:43













@davidgo the shell was started when on gnome and it is tty. I can't install VNC on this machine

– tomasz74
Jan 23 at 18:46





@davidgo the shell was started when on gnome and it is tty. I can't install VNC on this machine

– tomasz74
Jan 23 at 18:46













I would recommend going forward to use: linux.die.net/man/1/screen

– kylie.a
Jan 24 at 1:42





I would recommend going forward to use: linux.die.net/man/1/screen

– kylie.a
Jan 24 at 1:42










3 Answers
3






active

oldest

votes


















5














There's this answer on ServerFault:




setterm can dump the contents of a Linux virtual console:



setterm -file log.txt -dump [ttynumbers]


However, it does not have access to the scrollback buffer, only to what's currently displayed.




This will work if you want to peek into /dev/tty?, not /dev/pts/*, I think. Use ps -e to identify the tty number of the shell in question. During my tests I have successfully dumped /dev/tty2 with the following command:



sudo setterm -file log.txt -dump 2





share|improve this answer

































    2














    While you cannot view what's already happened (unless you can get that session back) there's an excellent tool called tmux which helps with this.



    Simply install (sudo apt install tmux), run it (tmux) and then run the process you want inside the tmux terminal. Then hit Ctrl+B, then D, to detach it - this will get you back to your previous shell and you can close the terminal. Then, connect to it from SSH or open another terminal (whatever you fancy) and run tmux attach. That will get you back to your terminal. There are other options to explore, but this is a basic form of using tmux across different terminal sessions.






    share|improve this answer



















    • 3





      This should be a comment as it does not answer the OP's question. (Also, the screen utility does something similar)

      – davidgo
      Jan 23 at 20:44



















    1














    The traditional tool for recording a terminal session is script. It is widely available, usually by default, on most Unix and Unix-like systems.



    Some terminal emulators, including xterm of course, and some pc terminal emulators often used on the so-called "console" device of a desktop machine (i.e. the directly connected keyboard and display), do have a scrollback buffer and you can scroll back to see previous activity, and you might even be able to copy and paste it from the scrolled back view.



    Indeed, the lesson here is that (most) TTY devices do not record anything -- they simply pass it through. One must arrange for one's own recording, be that by starting a script or similar recording tool, or by using an appropriate terminal emulator.



    (BTW, some systems also have a "console buffer" as well, but it only records output from the kernel itself, and it is accessed with a command usually called dmesg.)






    share|improve this answer


























    • Can script work retrospectively?

      – Kamil Maciorowski
      Jan 24 at 6:34











    • it is a very good tip, but I can't find a way to view an already existing output. Anyway, probably next time will run it with some script option.

      – tomasz74
      Jan 24 at 9:03











    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "3"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1397590%2fviewing-bash-output-from-another-shell-retrospectively%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    5














    There's this answer on ServerFault:




    setterm can dump the contents of a Linux virtual console:



    setterm -file log.txt -dump [ttynumbers]


    However, it does not have access to the scrollback buffer, only to what's currently displayed.




    This will work if you want to peek into /dev/tty?, not /dev/pts/*, I think. Use ps -e to identify the tty number of the shell in question. During my tests I have successfully dumped /dev/tty2 with the following command:



    sudo setterm -file log.txt -dump 2





    share|improve this answer






























      5














      There's this answer on ServerFault:




      setterm can dump the contents of a Linux virtual console:



      setterm -file log.txt -dump [ttynumbers]


      However, it does not have access to the scrollback buffer, only to what's currently displayed.




      This will work if you want to peek into /dev/tty?, not /dev/pts/*, I think. Use ps -e to identify the tty number of the shell in question. During my tests I have successfully dumped /dev/tty2 with the following command:



      sudo setterm -file log.txt -dump 2





      share|improve this answer




























        5












        5








        5







        There's this answer on ServerFault:




        setterm can dump the contents of a Linux virtual console:



        setterm -file log.txt -dump [ttynumbers]


        However, it does not have access to the scrollback buffer, only to what's currently displayed.




        This will work if you want to peek into /dev/tty?, not /dev/pts/*, I think. Use ps -e to identify the tty number of the shell in question. During my tests I have successfully dumped /dev/tty2 with the following command:



        sudo setterm -file log.txt -dump 2





        share|improve this answer















        There's this answer on ServerFault:




        setterm can dump the contents of a Linux virtual console:



        setterm -file log.txt -dump [ttynumbers]


        However, it does not have access to the scrollback buffer, only to what's currently displayed.




        This will work if you want to peek into /dev/tty?, not /dev/pts/*, I think. Use ps -e to identify the tty number of the shell in question. During my tests I have successfully dumped /dev/tty2 with the following command:



        sudo setterm -file log.txt -dump 2






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Jan 23 at 18:59

























        answered Jan 23 at 18:52









        Kamil MaciorowskiKamil Maciorowski

        26.1k155680




        26.1k155680

























            2














            While you cannot view what's already happened (unless you can get that session back) there's an excellent tool called tmux which helps with this.



            Simply install (sudo apt install tmux), run it (tmux) and then run the process you want inside the tmux terminal. Then hit Ctrl+B, then D, to detach it - this will get you back to your previous shell and you can close the terminal. Then, connect to it from SSH or open another terminal (whatever you fancy) and run tmux attach. That will get you back to your terminal. There are other options to explore, but this is a basic form of using tmux across different terminal sessions.






            share|improve this answer



















            • 3





              This should be a comment as it does not answer the OP's question. (Also, the screen utility does something similar)

              – davidgo
              Jan 23 at 20:44
















            2














            While you cannot view what's already happened (unless you can get that session back) there's an excellent tool called tmux which helps with this.



            Simply install (sudo apt install tmux), run it (tmux) and then run the process you want inside the tmux terminal. Then hit Ctrl+B, then D, to detach it - this will get you back to your previous shell and you can close the terminal. Then, connect to it from SSH or open another terminal (whatever you fancy) and run tmux attach. That will get you back to your terminal. There are other options to explore, but this is a basic form of using tmux across different terminal sessions.






            share|improve this answer



















            • 3





              This should be a comment as it does not answer the OP's question. (Also, the screen utility does something similar)

              – davidgo
              Jan 23 at 20:44














            2












            2








            2







            While you cannot view what's already happened (unless you can get that session back) there's an excellent tool called tmux which helps with this.



            Simply install (sudo apt install tmux), run it (tmux) and then run the process you want inside the tmux terminal. Then hit Ctrl+B, then D, to detach it - this will get you back to your previous shell and you can close the terminal. Then, connect to it from SSH or open another terminal (whatever you fancy) and run tmux attach. That will get you back to your terminal. There are other options to explore, but this is a basic form of using tmux across different terminal sessions.






            share|improve this answer













            While you cannot view what's already happened (unless you can get that session back) there's an excellent tool called tmux which helps with this.



            Simply install (sudo apt install tmux), run it (tmux) and then run the process you want inside the tmux terminal. Then hit Ctrl+B, then D, to detach it - this will get you back to your previous shell and you can close the terminal. Then, connect to it from SSH or open another terminal (whatever you fancy) and run tmux attach. That will get you back to your terminal. There are other options to explore, but this is a basic form of using tmux across different terminal sessions.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Jan 23 at 18:40









            QuickishFMQuickishFM

            1465




            1465








            • 3





              This should be a comment as it does not answer the OP's question. (Also, the screen utility does something similar)

              – davidgo
              Jan 23 at 20:44














            • 3





              This should be a comment as it does not answer the OP's question. (Also, the screen utility does something similar)

              – davidgo
              Jan 23 at 20:44








            3




            3





            This should be a comment as it does not answer the OP's question. (Also, the screen utility does something similar)

            – davidgo
            Jan 23 at 20:44





            This should be a comment as it does not answer the OP's question. (Also, the screen utility does something similar)

            – davidgo
            Jan 23 at 20:44











            1














            The traditional tool for recording a terminal session is script. It is widely available, usually by default, on most Unix and Unix-like systems.



            Some terminal emulators, including xterm of course, and some pc terminal emulators often used on the so-called "console" device of a desktop machine (i.e. the directly connected keyboard and display), do have a scrollback buffer and you can scroll back to see previous activity, and you might even be able to copy and paste it from the scrolled back view.



            Indeed, the lesson here is that (most) TTY devices do not record anything -- they simply pass it through. One must arrange for one's own recording, be that by starting a script or similar recording tool, or by using an appropriate terminal emulator.



            (BTW, some systems also have a "console buffer" as well, but it only records output from the kernel itself, and it is accessed with a command usually called dmesg.)






            share|improve this answer


























            • Can script work retrospectively?

              – Kamil Maciorowski
              Jan 24 at 6:34











            • it is a very good tip, but I can't find a way to view an already existing output. Anyway, probably next time will run it with some script option.

              – tomasz74
              Jan 24 at 9:03
















            1














            The traditional tool for recording a terminal session is script. It is widely available, usually by default, on most Unix and Unix-like systems.



            Some terminal emulators, including xterm of course, and some pc terminal emulators often used on the so-called "console" device of a desktop machine (i.e. the directly connected keyboard and display), do have a scrollback buffer and you can scroll back to see previous activity, and you might even be able to copy and paste it from the scrolled back view.



            Indeed, the lesson here is that (most) TTY devices do not record anything -- they simply pass it through. One must arrange for one's own recording, be that by starting a script or similar recording tool, or by using an appropriate terminal emulator.



            (BTW, some systems also have a "console buffer" as well, but it only records output from the kernel itself, and it is accessed with a command usually called dmesg.)






            share|improve this answer


























            • Can script work retrospectively?

              – Kamil Maciorowski
              Jan 24 at 6:34











            • it is a very good tip, but I can't find a way to view an already existing output. Anyway, probably next time will run it with some script option.

              – tomasz74
              Jan 24 at 9:03














            1












            1








            1







            The traditional tool for recording a terminal session is script. It is widely available, usually by default, on most Unix and Unix-like systems.



            Some terminal emulators, including xterm of course, and some pc terminal emulators often used on the so-called "console" device of a desktop machine (i.e. the directly connected keyboard and display), do have a scrollback buffer and you can scroll back to see previous activity, and you might even be able to copy and paste it from the scrolled back view.



            Indeed, the lesson here is that (most) TTY devices do not record anything -- they simply pass it through. One must arrange for one's own recording, be that by starting a script or similar recording tool, or by using an appropriate terminal emulator.



            (BTW, some systems also have a "console buffer" as well, but it only records output from the kernel itself, and it is accessed with a command usually called dmesg.)






            share|improve this answer















            The traditional tool for recording a terminal session is script. It is widely available, usually by default, on most Unix and Unix-like systems.



            Some terminal emulators, including xterm of course, and some pc terminal emulators often used on the so-called "console" device of a desktop machine (i.e. the directly connected keyboard and display), do have a scrollback buffer and you can scroll back to see previous activity, and you might even be able to copy and paste it from the scrolled back view.



            Indeed, the lesson here is that (most) TTY devices do not record anything -- they simply pass it through. One must arrange for one's own recording, be that by starting a script or similar recording tool, or by using an appropriate terminal emulator.



            (BTW, some systems also have a "console buffer" as well, but it only records output from the kernel itself, and it is accessed with a command usually called dmesg.)







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Jan 24 at 18:45

























            answered Jan 24 at 0:15









            Greg A. WoodsGreg A. Woods

            201310




            201310













            • Can script work retrospectively?

              – Kamil Maciorowski
              Jan 24 at 6:34











            • it is a very good tip, but I can't find a way to view an already existing output. Anyway, probably next time will run it with some script option.

              – tomasz74
              Jan 24 at 9:03



















            • Can script work retrospectively?

              – Kamil Maciorowski
              Jan 24 at 6:34











            • it is a very good tip, but I can't find a way to view an already existing output. Anyway, probably next time will run it with some script option.

              – tomasz74
              Jan 24 at 9:03

















            Can script work retrospectively?

            – Kamil Maciorowski
            Jan 24 at 6:34





            Can script work retrospectively?

            – Kamil Maciorowski
            Jan 24 at 6:34













            it is a very good tip, but I can't find a way to view an already existing output. Anyway, probably next time will run it with some script option.

            – tomasz74
            Jan 24 at 9:03





            it is a very good tip, but I can't find a way to view an already existing output. Anyway, probably next time will run it with some script option.

            – tomasz74
            Jan 24 at 9:03


















            draft saved

            draft discarded




















































            Thanks for contributing an answer to Super User!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1397590%2fviewing-bash-output-from-another-shell-retrospectively%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            How to change which sound is reproduced for terminal bell?

            Can I use Tabulator js library in my java Spring + Thymeleaf project?

            Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents