6,534
edits
Changes
Fixed list formatting, added -f description
But what can you do, if logs are poor and it's impossible to infer the reason of badness from them?
One way is to use strace program to follow system calls performed by given process.
Commonly to use strace you should give the following command:
<ttpre>strace -o strace.out -ff touch /tmp/file</ttpre>
Here * <tt>-o strace.out</tt> option means that strace program will output all investigated informationto the file named <tt>strace.out</tt>; * <tt>touch /tmp/file-ff</tt> is means to strace the forked children of the program with arguments . Child straces outputs will be placed to <tt>strace .out.PID</tt> files, where PID is a pid of the child. If you want all the process under strace (touch in our case) forks child processesoutput to a single file, then, thanks to use <tt>-fff</tt> argument instead (i.e. single <tt>f</tt> option, child processesnot double).are straced too, and ouputs are placed in * <tt>strace.out.PIDtouch /tmp/file</tt> files appropriatelyis the program with arguments which is to be straced.
== Strace results ==
So this is what we have in <tt>strace.out</tt>:
<pre>
execve("/usr/bin/touch", ["touch", "/tmp/file"], [/* 51 vars */]) = 0
</pre>
== Additional notes ==
Sometimes (for example if a program works slow) you are also intersted in time, that the program spends in syscalls. Than
options <tt>-tt</tt> and <tt>-T</tt> are helpful.
As you've seen strace program shows arguments of syscalls. But if arguments are a pointers it shows us only 32 bytes from these pointers.To increase this number use <tt>-s</tt> option. [[Category: Troubleshooting]]