可以的,nohup 在 Linux 中完全支持日志重定向。
使用 nohup 运行命令时,如果不显式重定向,标准输出(stdout)和标准错误(stderr)会默认写入当前目录的:
nohup.out
nohup your_command > app.log 2>&1 &
说明:
>:重定向标准输出2>&1:将标准错误合并到标准输出&:后台运行nohup your_command > out.log 2> err.log &
nohup your_command >> app.log 2>&1 &
nohup your_command > /dev/null 2>&1 &
nohup python main.py > run.log 2>&1 &
jobs
# 或
ps aux | grep main.py
✅ nohup 日志可以且推荐重定向
✅ 通常写法:nohup cmd > log 2>&1 &
✅ 可避免 nohup.out 无限增大
如果你有具体命令或场景(如 Java / Python / Shell),我也可以给你更合适的写法。