使 nohup 写入 nohup.out 以外的内容
make nohup write other than nohup.out
我一直在使用下面的命令让 tail 写入 nohup.out 并在终端上打印输出。
nohup train.py & tail -f nohup.out
但是,我需要 nohup 才能使用不同的文件名。
当我尝试时
nohup python train.py & tail -F vanila_v1.out
我收到以下错误消息。
tail: cannot open 'vanila_v1.out' for readingnohup: ignoring input and appending output to 'nohup.out': No such file or directory
我也试过了
nohup python train.py & tail -F nohup.out > vanila_v1.txt
然后它不会在标准输出上写入输出。
除了 nohup.out
之外,我如何让 nohup 写入?我不介意同时写两个不同的文件。但是为了跟踪不同的进程,我需要不同的名称。
谢谢。
您需要为 nohup 命令传递 STDOUT
和 STDERR
,例如:
$ nohup python train.py > vanila_v1.out 2>&1 & tail -F vanila_v1.out
此时进程会进入后台,可以使用tail -f vanila_v1.out
。这是一种方法。
此处提供了更多有关 STDOUT
和 STDERR
link. Here is another question 的信息,它们使用 tee 命令而不是 >
一次性实现相同的目的。
我一直在使用下面的命令让 tail 写入 nohup.out 并在终端上打印输出。
nohup train.py & tail -f nohup.out
但是,我需要 nohup 才能使用不同的文件名。
当我尝试时
nohup python train.py & tail -F vanila_v1.out
我收到以下错误消息。
tail: cannot open 'vanila_v1.out' for readingnohup: ignoring input and appending output to 'nohup.out': No such file or directory
我也试过了
nohup python train.py & tail -F nohup.out > vanila_v1.txt
然后它不会在标准输出上写入输出。
除了 nohup.out
之外,我如何让 nohup 写入?我不介意同时写两个不同的文件。但是为了跟踪不同的进程,我需要不同的名称。
谢谢。
您需要为 nohup 命令传递 STDOUT
和 STDERR
,例如:
$ nohup python train.py > vanila_v1.out 2>&1 & tail -F vanila_v1.out
此时进程会进入后台,可以使用tail -f vanila_v1.out
。这是一种方法。
此处提供了更多有关 STDOUT
和 STDERR
link. Here is another question 的信息,它们使用 tee 命令而不是 >
一次性实现相同的目的。