strace $(pgrep httpd | awk '{ print "-p " $1 }' | tr '\n' ' ')
(it's left as exercise to the reader to understand what it does) if you want to save the output and the play with it, just add '-o <file>'.
Welcome, new handy tool!
A blog about things I do: Debian, Linux, Python, whatever
strace $(pgrep httpd | awk '{ print "-p " $1 }' | tr '\n' ' ')
5 comments:
For completeness' sake, you could also use:
# pgrep httpd | sed 's/^/-p /' | xargs strace
Seems a bit easier to read, IMHO. Though naturally not so cool! :)
BTW, it seems xargs could use some sort of argument like "automatically prepend arguments with X". Would neatly make this sort of hack useless.
Also can be written as:
strace $(printf -- '-p %s ' $(pgrep httpd) )
Thanks for sharing :)
Or
strace -p$(pgrep -d\ -p httpd)
I usually use:
for i in $(ps -eLf |grep NAME |awk '{print $4}'); do (strace -p $i 2>&1 &); done
Leo, you mean like this:
pgrep httpd | xargs -i strace -p {}
Post a Comment