Trace a new process

Run a command under strace and save output to file

strace -o trace.log ls /tmp

tool
strace13 commands
tags
stracelinuxdebug

More strace commands

  • strace -p $(pgrep nginx | head -1) -o /tmp/nginx.trace

    Trace syscalls of an already-running process by PID

  • strace -e trace=openat,read,write curl https://example.com

    Filter to file-related syscalls only

  • strace -c -e trace=all python3 app.py

    Summary table of syscall counts and time spent

  • strace -f -e trace=process nginx -t

    Trace syscalls in all forked children (-f)

  • strace -tt -T curl https://example.com 2>&1 | head -40

    -tt adds absolute time; -T shows time spent in each call

all 13 strace commands