在 CentOS(或其他 Linux 系统)中,使用 nohup 启动的进程,其日志和进程本身可以通过下面几种方式查找。
ps + grepps -ef | grep nohup
或针对某个命令:
ps -ef | grep your_program
示例:
ps -ef | grep java
pgreppgrep -f your_program
例如:
pgrep -f nohup
ps -aux | grep nohup
可以看到:
如果你是这样启动的:
nohup command &
日志默认会写入:
nohup.out
位置在你执行命令的当前目录。
查找:
ls -l nohup.out
如果你这样启动:
nohup command > app.log 2>&1 &
那么日志就在:
app.log
查找日志文件:
find / -name "nohup.out" 2>/dev/null
或
find / -name "*.log" 2>/dev/null
lsof -p PID
示例:
lsof -p 12345
在输出中找:
nohup.outapp.log/proc 文件系统ls -l /proc/PID/fd
示例:
ls -l /proc/12345/fd
可以看到标准输出(1)和标准错误(2)指向的日志文件。
tail -f nohup.out
或
tail -f app.log
ps -ef | grep nohup
tail -f nohup.out
netstat -tunlp | grep 8080
或
ss -tunlp | grep 8080
如果你能告诉我:
我可以给你更精确的命令。