20120416 strace for debugging linux apps - plembo/onemoretech GitHub Wiki

title: strace for debugging Linux apps link: https://onemoretech.wordpress.com/2012/04/16/strace-for-debugging-linux-apps/ author: lembobro description: post_id: 2541 created: 2012/04/16 12:06:12 created_gmt: 2012/04/16 16:06:12 comment_status: closed post_name: strace-for-debugging-linux-apps status: publish post_type: post

strace for debugging Linux apps

The strace command is a terrific tool for debugging application issues on Linux. More below. The strace command on Linux, like its cousin, truss on Solaris, can be very useful in tracking down exactly what is going wrong with a particular command or daemon. Like truss, the strace command has a number of options that are worth becoming familiar with. Basic operation of strace is simple:

strace /usr/sbin/httpd

In most cases you'll want to generate a file to capture the output for more detailed analysis:

strace -o strace.out /usr/sbin/httpd

Because many daemons fork additional processes, the "-f" option is also recommended:

strace -o strace.out -f /usr/sbin/httpd

To check a running process, use the "-p" option with the process number:

strace -o strace.out -fp 48511

When using this last mode you'll need to CNTRL-c to exit tracing.

Copyright 2004-2019 Phil Lembo