bash 在拒绝和注销后是否可以看到输出到标准输出?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1006745/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 20:58:58  来源:igfitidea点击:

Is it possible to see output to stdout after disown and logout?

linuxbash

提问by omg

I have done this to that programe: ctrl-z disown -h %1 bg 1

我已经对那个程序做了这个: ctrl-z disown -h %1 bg 1

then logout,

然后退出,

Is it still possible for me to see what that programe outputs to stdout now?

我现在还能看到程序输出到标准输出的内容吗?

回答by Chas. Owens

General screenusage:

一般screen用法

user@machine:/home/user$ screen bash -l
user@machine:/home/user$ long_running_program
<user presses ctrl-a d to detach from the screen session>
user@machine:/home/user$ screen -ls
There is a screen on:
        58356.ttys000.machine     (Detached)
1 Socket in /tmp/uscreens/S-user.
user@machine:/home/user$ screen -r 58356
<user is connected to the original screen session>

回答by mog

ctrl-z the program
bg %  so it wont die when you logoff
screen retty $Pid
will attach the running program into screen

duplicate question of how to replace the "disown" with "screen"?

如何用“屏幕”替换“disown”的重复问题

回答by phreakocious

This should be possible..

这个应该可以。。

Yes, this is an old question, but I'm sure others have been in the same position. This gentleman's gdb script wizardry allows one to "repoint" file descriptors in running processes. It can be done per-process by PID, or will call fuser to find all processes using the file. I also just confirmed it works on /dev/pty/*, so STD(IN,OUT,ERR) are possible as well.

是的,这是一个老问题,但我相信其他人也处于同样的位置。这位绅士的 gdb 脚本向导允许在运行的进程中“重新指向”文件描述符。它可以通过 PID 为每个进程完成,或者将调用 fuser 来查找使用该文件的所有进程。我也刚刚确认它适用于 /dev/pty/*,所以 STD(IN,OUT,ERR) 也是可能的。

http://groups.google.com/group/alt.hackers/browse_thread/thread/d1932c31ce43bd4c

http://groups.google.com/group/alt.hackers/browse_thread/thread/d1932c31ce43bd4c

.

.

Same as the answer I posted here: how to replace the "disown" with "screen"?

与我在这里发布的答案相同: 如何将“disown”替换为“screen”?

回答by coredump

Don't know if it will help you, but you could call "gdb" and change the file descriptor. See http://blog.tridgell.net/?p=4

不知道它是否会帮助你,但你可以调用“gdb”并更改文件描述符。见http://blog.tridgell.net/?p=4

回答by Brian Agnew

Not if you've logged out. The process will be writing stdout to the pty that was allocated on login, and logging out will remove this allocation. You'll have to redirect the stdout to a file, and then tail that.

如果您已注销,则不会。该进程会将 stdout 写入登录时分配的 pty,注销将删除此分配。您必须将标准输出重定向到一个文件,然后拖尾。