【问题标题】:How can I look into nohup file while the program is still running?在程序仍在运行时如何查看 nohup 文件?
【发布时间】:2015-10-23 18:30:03
【问题描述】:

我正在使用

nohup ./program_name & 

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

【问题讨论】:

  • 而不是使用nohup,也许您应该使用screen 或tmux 进行调查 - 这样您就不必将输出重定向到文件并处理所涉及的缓冲延迟。 ..

标签: linux unix ssh nohup


【解决方案1】:

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

tail -f nohup.out 

用于流输出

【讨论】:

    【解决方案2】:

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

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

    然后,你可以使用tail来监控programName.log:

    tail -f /tmp/programName.log

    【讨论】:

      【解决方案3】:

      将以下命令放在程序运行的当前终端中

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

         jobs -l
      

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

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2011-08-20
        • 2012-07-29
        • 1970-01-01
        • 2011-01-10
        • 2019-11-02
        • 1970-01-01
        相关资源
        最近更新 更多