When logs don’t help, strace/ltrace are the safety net.
strace¶
strace ls /tmp
strace -p 1234
strace -e open,read,write ls /tmp
strace -c ls /tmp
Examples¶
strace -e openat ./app 2>&1 | grep error
strace -e write -p $(pgrep myapp)
strace -c -p $(pgrep myapp) # where it spends time
ltrace¶
ltrace ./my-program
ltrace -e malloc+free ./my-program
- -f = child processes
- -s 1000 = longer strings
- Use briefly in production
Ultimate debugging¶
strace will save hours of troubleshooting.
straceltracedebugging