在 Linux 中,nohup 命令通常会把程序的输出重定向到当前目录下的 nohup.out 文件。如果你想“导出日志”或“管理日志”,常见做法如下:
nohup your_command &
日志会写到:
nohup.out
查看日志:
tail -f nohup.out
你可以自己指定日志文件:
nohup your_command > app.log 2>&1 &
说明:
>:标准输出2>&1:错误输出也写入同一文件&:后台运行查看日志:
tail -f app.log
nohup your_command > out.log 2> err.log &
nohup your_command >> app.log 2>&1 &
cp nohup.out app_$(date +%F).log
或清空:
> nohup.out
如果日志很大,建议用 logrotate 或 split:
split -b 100M nohup.out log_part_
如果你能说一下:
我可以给你更精确的命令。