在 CentOS(以及大多数 Linux 系统)中,nohup 命令通常配合输出重定向使用,以避免日志直接刷屏或丢失。
nohup your_command > output.log 2>&1 &
含义:
>:标准输出重定向到 output.log2>&1:标准错误也重定向到标准输出(即同一个日志文件)&:后台运行nohup your_command > out.log 2> err.log &
nohup your_command >> output.log 2>&1 &
nohup your_command > /dev/null 2>&1 &
nohup 默认日志如果不指定重定向:
nohup your_command &
默认会生成:
nohup.out
(在当前目录,容易堆积,不推荐)
jobs
# 或
ps -ef | grep your_command
tail -f output.log
如果你有 具体命令场景(如 Java、Python、Shell 脚本),我可以给你更精确的写法。