10

I'm running dtruss on Mac OS X 10.9. Simple example is:

sudo -c ls

But I'd like to capture the dtruss output into a file. I saw something that suggests that I can do something like:

sudo bash -c 'dtruss -c ls >x'

but when I do this the output of dtruss still goes to the terminal and the list of file from ls gets redirected to the file.

How can I redirect the output of dtruss to a file?

1
  • 1
    dtruss probably writes to stderr instead of stdout witch is what >x captures. This questions explains what to do: Linux less behavior and stderr
    – Nifle
    Commented Jul 8, 2014 at 15:05

1 Answer 1

9

I've been running it like this:

sudo dtruss -f -p 12345 2> /tmp/trace.txt
  • -f says to follow child processes.
  • -p specifies which process ID to trace.
  • 12345 is a placeholder for a process ID. You could get that by looking at top or ps -A.
  • 2> pipes standard error into the output file. For some reason dtruss outputs everything on stderr.
4
  • Could you expand your answer to explain what this does? Thanks.
    – fixer1234
    Commented Mar 6, 2015 at 4:47
  • '-f' says follow child processes, '-p' specifies which process ID to trace, '2>' pipes standard error into the output file. For some reason dtruss outputs everything on stderr. Commented Mar 6, 2015 at 5:17
  • Is 12345 a placeholder for the process ID (and where would that come from)?
    – fixer1234
    Commented Mar 6, 2015 at 5:23
  • It is a placeholder for a process ID. You could get that by looking at top or ps -A. Commented Mar 6, 2015 at 6:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .