Attach to a running process
Trace the syscalls of a process that is already running, by PID
strace -p $(pgrep nginx | head -1) -o /tmp/nginx.trace
- tool
- strace13 commands
More strace commands
-
strace -e trace=openat,read,write curl https://example.comShow only openat, read and write calls and hide the rest
-
strace -c -e trace=all python3 app.pyPrint a summary table with the count and time of each syscall
-
strace -f -e trace=process nginx -tTrace process syscalls like fork and exec in all child processes (-f)
-
strace -tt -T curl https://example.com 2>&1 | head -40-tt adds the wall-clock time, -T shows how long each call took
-
strace -e trace=openat -e trace=file myapp 2>&1 | grep 'ENOENT'Find files that the process tries to open but cannot find