use*_*ser 5 terminal io-redirection nohup background-process output
如果将 nohup 应用程序重定向为:
nohup bash -c "printf \"command\n\"" &> /dev/null
Run Code Online (Sandbox Code Playgroud)
该nohup.out文件未创建,但是我运行命令的终端也没有得到任何输出。如何保留命令的终端输出但不创建文件nohup.out?
尝试这个,
要在控制台和 nohup.out 文件中获取STDOUT和,请在执行命令之前执行以下命令。STDERRnohup
exec > >(awk '{ print $0; fflush();}' | tee -a nohup.out)
exec 2> >(awk '{ print $0; fflush();}' | tee -a nohup.out >&2)
nohup bash -c "printf \"command\n\"" &
Run Code Online (Sandbox Code Playgroud)
编辑:
如果你不想nohup.out创建,那么试试这个
exec > >(awk '{ print $0; fflush();}')
exec 2> >(awk '{ print $0; fflush();}')
nohup bash -c "printf \"command\n\"" &
Run Code Online (Sandbox Code Playgroud)
这不会在控制台上nohup.out显示时创建STDOUT和。STDERR
将以上几行放入脚本中,然后在后台运行它。
| 归档时间: |
|
| 查看次数: |
7091 次 |
| 最近记录: |