“远程查 nohup 日志”通常分两步:先远程连到服务器,再查看 nohup 输出的日志文件。下面按常见场景说明。
ssh user@远程服务器IP
例如:
ssh root@192.168.1.100
如果有端口:
ssh -p 22 user@host
如果你是这样启动的:
nohup python app.py &
日志默认在:
nohup.out
查看:
ls -l nohup.out
nohup python app.py > app.log 2>&1 &
日志就在:
app.log
tail -f nohup.out
或
tail -f app.log
退出:Ctrl + C
tail -n 100 nohup.out
cat nohup.out
或分页:
less nohup.out
q 退出
grep "ERROR" nohup.out
ssh user@host "tail -f /path/to/nohup.out"
ssh user@host "tail -f /home/user/app/app.log"
find / -name nohup.out 2>/dev/null
python -u app.py > app.log 2>&1 &
如果你愿意,可以告诉我:
我可以给你更精确的命令。