nohup 命令用于在后台运行程序,即使关闭终端或断开连接,程序也会继续运行。默认情况下,nohup 会将程序的输出重定向到名为 nohup.out 的文件中。如果你想将输出分散到多个文件中,可以使用 shell 的输出重定向功能。
以下是一些示例:
nohup your_command > output.log 2> error.log &
这里,your_command 是你要运行的命令,output.log 是标准输出的目标文件,error.log 是标准错误的目标文件。& 符号将命令放入后台运行。
nohup your_command > output_%Y-%m-%d.log 2>&1 &
这里,%Y-%m-%d 是一个日期格式,它将在每天创建一个新的日志文件。
tee 命令将输出同时显示在终端并保存到文件:nohup your_command | tee output.log &
这里,tee 命令将同时将输出发送到 output.log 文件和终端。
你可以根据需要修改这些示例,以便将输出分散到多个文件中。