Return访问nohup.out后提示(bash)
Return prompt after accessing nohup.out (bash)
我正在 运行使用 nohup
从 bash 中创建一个 Python 脚本。该脚本作为 shell 函数的一部分通过我的 bashrc 执行。如果我 运行 是这样的:
function timer {
nohup python path/timer.py > path/nohup.out 2>&1 &
echo 'blah'
}
一切正常,我得到了提示。但是,如果我调用 tail
而不是 echo
来访问 nohup 输出文件的结尾,如下所示:
function timer {
nohup python path/timer.py > path/nohup.out 2>&1 &
tail -f path/nohup.out
}
我的提示没有返回。我想查看 nohup.out 的内容并返回提示,而不必使用 CTRL-c。
我听从了建议 here,但是添加 </dev/null
会产生与上面相同的结果。
您不会收到提示。
因为,tail -f
将始终监视文件 (path/nohup.out
) 以随着文件的增长输出附加数据。您可以尝试 tail -n
获取 path/nohup.out
.
的最后 10
行
我正在 运行使用 nohup
从 bash 中创建一个 Python 脚本。该脚本作为 shell 函数的一部分通过我的 bashrc 执行。如果我 运行 是这样的:
function timer {
nohup python path/timer.py > path/nohup.out 2>&1 &
echo 'blah'
}
一切正常,我得到了提示。但是,如果我调用 tail
而不是 echo
来访问 nohup 输出文件的结尾,如下所示:
function timer {
nohup python path/timer.py > path/nohup.out 2>&1 &
tail -f path/nohup.out
}
我的提示没有返回。我想查看 nohup.out 的内容并返回提示,而不必使用 CTRL-c。
我听从了建议 here,但是添加 </dev/null
会产生与上面相同的结果。
您不会收到提示。
因为,tail -f
将始终监视文件 (path/nohup.out
) 以随着文件的增长输出附加数据。您可以尝试 tail -n
获取 path/nohup.out
.
10
行