| 用途 | 跟踪进程的系统调用与信号 |
|---|---|
| 语法 | strace [选项] 命令 | strace -p PID |
| 所属 | strace 软件包 |
常用示例
常用示例
strace -f -tt -e trace=openat,connect /opt/myapp/bin/start 2>&1 | tail -n 40
strace -p $(pgrep -f app.jar | head -1) -c # 汇总统计
strace -e trace=file -f ./script.sh 2>&1 | grep -E 'ENOENT|EACCES' | head输出到文件
输出到文件
strace -f -o /tmp/trace.log ./run.sh && grep -n EACCES /tmp/trace.log | headstrace 会显著拖慢目标进程且可能被 seccomp/ptrace_scope 限制;生产大流量进程慎 attach,优先短时抓取。