Get latest output of a running command
Clash Royale CLAN TAG#URR8PPP
up vote
2
down vote
favorite
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
add a comment |Â
up vote
2
down vote
favorite
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
add a comment |Â
up vote
2
down vote
favorite
up vote
2
down vote
favorite
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
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
monitoring proc output
asked 3 hours ago
Mike V.D.C.
1263
1263
add a comment |Â
add a comment |Â
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.
add a comment |Â
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.
add a comment |Â
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.
add a comment |Â
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.
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.
edited 1 hour ago
answered 2 hours ago
mosvy
3,190119
3,190119
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password