温馨提示×

linux nohup日志怎么实时看

小樊
36
2026-10-21 01:11:58
栏目: 智能运维

在 Linux 下用 nohup 启动程序时,通常会把输出重定向到日志文件,例如:

nohup your_command > app.log 2>&1 &

要实时查看日志,常用以下几种方式:


1. tail -f(最常用)

实时跟踪文件新增内容:

tail -f app.log

如果日志会轮转(被截断/重建),用:

tail -F app.log

(-F 会监听文件是否被替换)


2. less +F(可交互)

less +F app.log
  • 实时刷新(类似 tail -f)
  • 按 Ctrl + C 停止刷新,可搜索(/关键字)
  • 按 F 恢复实时跟踪

3. multitail(多日志同时看)

适合同时看多个日志:

multitail app.log

(需安装:yum install multitail / apt install multitail)


4. 结合 grep 实时过滤

tail -f app.log | grep ERROR

小提示

  • nohup 默认日志是 nohup.out
  • 如果程序没输出,确认是否真的写入了日志文件
  • 后台任务可用 jobs / ps aux | grep your_command 查看

如果你说的是 Docker / systemd / supervisor 里的日志,也可以告诉我,我给你对应命令。

0 踩