我如何在程序仍然 运行 时查看 nohup 文件?

How can I look into nohup file while the program is still running?

我正在使用

nohup ./program_name & 

到 运行 我的程序,program_name 打印出 运行ning 进程的一些值和状态,包括程序已完成的百分比,但由于我 运行使用 nohup 连接它,所以我看不到我的程序有多接近完成,无论如何我仍然可以获得该信息吗?

我们必须打开 nohup.out 才能看到输出。也许你想要

tail -f nohup.out 

用于流式输出

也许调整您的 nohup 命令行以将所有输出捕获到一个文件中:

nohup ./program_name > /tmp/programName.log 2>&1 &

然后,您可以使用 tail:

监控 programName.log

tail -f /tmp/programName.log

在程序所在的当前终端中输入以下命令运行

jobs 命令用于列出您在后台和前台运行的工作

   jobs -l

[6]+ 6069 运行 nohup perl test1.pl &

[6]+ 6069 完成 nohup perl test1.pl