如何在Linux终端中再次打开进程? [英] How to open process again in linux terminal?

查看:443
本文介绍了如何在Linux终端中再次打开进程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从家用电脑上使用腻子,将其切入远程服务器,然后运行了一个python程序,该程序需要数小时才能完成,并且在运行时会打印出东西.现在过了一会儿,我的互联网断开了,我不得不关闭并重新打开腻子并重新打开ssh.如果键入"top",我可以看到python程序及其PID号在后台运行.我是否可以使用一条命令来基本上重新打开该过程,然后看到它再次打印出东西?

From my home pc using putty, I ssh'ed into a remote server, and I ran a python program that takes hours to complete, and as it runs it prints stuff. Now after a while, my internet disconnected, and I had to close and re-open putty and ssh back in. If I type 'top' I can see the python program running in the background with its PID number. Is there a command I can use to basically re-open that process and see it printing its stuff again?

谢谢

推荐答案

如前所述,最佳实践是使用screen或tmux(在启动程序之前,因此您无需提出此问题).

As noted, best practice is to use screen or tmux (before starting the program, so you do not need to ask this question).

但是,您也可以使用调试器(例如gdb)附加到正在运行的进程(还包含在此问题).总比没有好-但gdb和strace不会再给您程序的命令行(尽管

But you can also attach to a running process with a debugger such as gdb (alluded to here as ddd, a wrapper for gdb), as well as with strace (see this question). That's better than nothing - but gdb and strace would not give you the program's command-line again (though this question suggests a way). At least strace could give you some clues of what the program was attempting to print.

这篇关于如何在Linux终端中再次打开进程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆