Get latest output of a running command

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
2
down vote

favorite
1












I have a command running for a long time (which I dont want to disturb). However I would like to keep check on the process (most of the time remotely). I am constantly monitoring the process via commands like top, iotop, stat etc. the process is a terminal based process which wasnt started via screen or tmux or similar. So the only way to check the output is using a physical access.



I know that /proc contains lot of info about the process. So I was wondering if it also can display the output (or even just the last batch of output -- char/word/line). I searched in /proc/<pid>/fd, but coundnt find anything useful.



Below is the output of ls -l /proc/26745/fd/*



lrwx------ 1 user user 64 Oct 28 13:19 /proc/26745/fd/0 -> /dev/pts/17
lrwx------ 1 user user 64 Oct 28 13:19 /proc/26745/fd/1 -> /dev/pts/17
lrwx------ 1 user user 64 Sep 27 22:27 /proc/26745/fd/2 -> /dev/pts/17


Any pointers?










share|improve this question

























    up vote
    2
    down vote

    favorite
    1












    I have a command running for a long time (which I dont want to disturb). However I would like to keep check on the process (most of the time remotely). I am constantly monitoring the process via commands like top, iotop, stat etc. the process is a terminal based process which wasnt started via screen or tmux or similar. So the only way to check the output is using a physical access.



    I know that /proc contains lot of info about the process. So I was wondering if it also can display the output (or even just the last batch of output -- char/word/line). I searched in /proc/<pid>/fd, but coundnt find anything useful.



    Below is the output of ls -l /proc/26745/fd/*



    lrwx------ 1 user user 64 Oct 28 13:19 /proc/26745/fd/0 -> /dev/pts/17
    lrwx------ 1 user user 64 Oct 28 13:19 /proc/26745/fd/1 -> /dev/pts/17
    lrwx------ 1 user user 64 Sep 27 22:27 /proc/26745/fd/2 -> /dev/pts/17


    Any pointers?










    share|improve this question























      up vote
      2
      down vote

      favorite
      1









      up vote
      2
      down vote

      favorite
      1






      1





      I have a command running for a long time (which I dont want to disturb). However I would like to keep check on the process (most of the time remotely). I am constantly monitoring the process via commands like top, iotop, stat etc. the process is a terminal based process which wasnt started via screen or tmux or similar. So the only way to check the output is using a physical access.



      I know that /proc contains lot of info about the process. So I was wondering if it also can display the output (or even just the last batch of output -- char/word/line). I searched in /proc/<pid>/fd, but coundnt find anything useful.



      Below is the output of ls -l /proc/26745/fd/*



      lrwx------ 1 user user 64 Oct 28 13:19 /proc/26745/fd/0 -> /dev/pts/17
      lrwx------ 1 user user 64 Oct 28 13:19 /proc/26745/fd/1 -> /dev/pts/17
      lrwx------ 1 user user 64 Sep 27 22:27 /proc/26745/fd/2 -> /dev/pts/17


      Any pointers?










      share|improve this question













      I have a command running for a long time (which I dont want to disturb). However I would like to keep check on the process (most of the time remotely). I am constantly monitoring the process via commands like top, iotop, stat etc. the process is a terminal based process which wasnt started via screen or tmux or similar. So the only way to check the output is using a physical access.



      I know that /proc contains lot of info about the process. So I was wondering if it also can display the output (or even just the last batch of output -- char/word/line). I searched in /proc/<pid>/fd, but coundnt find anything useful.



      Below is the output of ls -l /proc/26745/fd/*



      lrwx------ 1 user user 64 Oct 28 13:19 /proc/26745/fd/0 -> /dev/pts/17
      lrwx------ 1 user user 64 Oct 28 13:19 /proc/26745/fd/1 -> /dev/pts/17
      lrwx------ 1 user user 64 Sep 27 22:27 /proc/26745/fd/2 -> /dev/pts/17


      Any pointers?







      monitoring proc output






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 3 hours ago









      Mike V.D.C.

      1263




      1263




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          2
          down vote













          I would use strace for that:



          strace -qfp PID -e trace=write -e write=1,2


          That will trace all write(2) system calls of PID and its child processes, and hexdump the data written to file descriptors 1 and 2.



          Of course, that won't let you see what the process has already written to the tty, but will start monitoring all writes from a point on.



          Also, strace is not amenable to change its output format -- you should explore using gdb(1) or write a small program using ptrace(2) if you need more flexibility.






          share|improve this answer






















            Your Answer







            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "106"
            ;
            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',
            convertImagesToLinks: false,
            noModals: false,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













             

            draft saved


            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f478214%2fget-latest-output-of-a-running-command%23new-answer', 'question_page');

            );

            Post as a guest






























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            2
            down vote













            I would use strace for that:



            strace -qfp PID -e trace=write -e write=1,2


            That will trace all write(2) system calls of PID and its child processes, and hexdump the data written to file descriptors 1 and 2.



            Of course, that won't let you see what the process has already written to the tty, but will start monitoring all writes from a point on.



            Also, strace is not amenable to change its output format -- you should explore using gdb(1) or write a small program using ptrace(2) if you need more flexibility.






            share|improve this answer


























              up vote
              2
              down vote













              I would use strace for that:



              strace -qfp PID -e trace=write -e write=1,2


              That will trace all write(2) system calls of PID and its child processes, and hexdump the data written to file descriptors 1 and 2.



              Of course, that won't let you see what the process has already written to the tty, but will start monitoring all writes from a point on.



              Also, strace is not amenable to change its output format -- you should explore using gdb(1) or write a small program using ptrace(2) if you need more flexibility.






              share|improve this answer
























                up vote
                2
                down vote










                up vote
                2
                down vote









                I would use strace for that:



                strace -qfp PID -e trace=write -e write=1,2


                That will trace all write(2) system calls of PID and its child processes, and hexdump the data written to file descriptors 1 and 2.



                Of course, that won't let you see what the process has already written to the tty, but will start monitoring all writes from a point on.



                Also, strace is not amenable to change its output format -- you should explore using gdb(1) or write a small program using ptrace(2) if you need more flexibility.






                share|improve this answer














                I would use strace for that:



                strace -qfp PID -e trace=write -e write=1,2


                That will trace all write(2) system calls of PID and its child processes, and hexdump the data written to file descriptors 1 and 2.



                Of course, that won't let you see what the process has already written to the tty, but will start monitoring all writes from a point on.



                Also, strace is not amenable to change its output format -- you should explore using gdb(1) or write a small program using ptrace(2) if you need more flexibility.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited 1 hour ago

























                answered 2 hours ago









                mosvy

                3,190119




                3,190119



























                     

                    draft saved


                    draft discarded















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f478214%2fget-latest-output-of-a-running-command%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    Comments

                    Popular posts from this blog

                    What does second last employer means? [closed]

                    List of Gilmore Girls characters

                    Confectionery