nohup 命令通常会把输出重定向到 nohup.out 或你指定的日志文件。要“过滤”日志内容,常见需求和做法如下:
tail -f nohup.out | grep "ERROR"
只看包含 ERROR 的日志。
tail -f nohup.out | grep -v "DEBUG"
不显示 DEBUG 日志。
tail -f nohup.out | grep -E "ERROR|WARN"
显示 ERROR 或 WARN。
grep "ERROR" nohup.out
grep -n "ERROR" nohup.out
grep -c "ERROR" nohup.out
grep "2024-01-01" nohup.out
nohup your_command 2> error.log 1> /dev/null &
nohup your_command > out.log 2> err.log &
nohup your_command 2>&1 | grep "ERROR" > error.log &
tail -n 100 nohup.out | grep "ERROR"
less nohup.out
在 less 中搜索:
/ERROR
tail -f nohup.out | grep --line-buffered "ERROR"
(--line-buffered 保证实时输出)
如果你能具体说明:
我可以给你更精确的命令。