Skip to main content
sysdig example
Source Link
thrig
  • 35.9k
  • 4
  • 70
  • 88

Replace the script with a wrapper that runs strace that in turn launches the original script. This might involve

mv yourscript /somewhere/else/yourscript 

and then yourscript becomes

#!/bin/sh OUTPUT_TO=`mktemp /tmp/yourscript.$$.XXXXXXXXXX` || exit 1 exec strace -o $OUTPUT_TO ... /somewhere/else/yourscript "$@" 

where ... is whatever other strace arguments you need.

As an alternative, consider sysdig, as it can trace by filename or username without the need for a process ID or wrapper script.:

sysdig -p '%fd.name' proc.name contains yourscript 

Replace the script with a wrapper that runs strace that in turn launches the original script. This might involve

mv yourscript /somewhere/else/yourscript 

and then yourscript becomes

#!/bin/sh OUTPUT_TO=`mktemp /tmp/yourscript.$$.XXXXXXXXXX` || exit 1 exec strace -o $OUTPUT_TO ... /somewhere/else/yourscript "$@" 

where ... is whatever other strace arguments you need.

As an alternative, consider sysdig, as it can trace by filename or username without the need for a process ID or wrapper script.

Replace the script with a wrapper that runs strace that in turn launches the original script. This might involve

mv yourscript /somewhere/else/yourscript 

and then yourscript becomes

#!/bin/sh OUTPUT_TO=`mktemp /tmp/yourscript.$$.XXXXXXXXXX` || exit 1 exec strace -o $OUTPUT_TO ... /somewhere/else/yourscript "$@" 

where ... is whatever other strace arguments you need.

As an alternative, consider sysdig, as it can trace by filename or username without the need for a process ID or wrapper script:

sysdig -p '%fd.name' proc.name contains yourscript 
Source Link
thrig
  • 35.9k
  • 4
  • 70
  • 88

Replace the script with a wrapper that runs strace that in turn launches the original script. This might involve

mv yourscript /somewhere/else/yourscript 

and then yourscript becomes

#!/bin/sh OUTPUT_TO=`mktemp /tmp/yourscript.$$.XXXXXXXXXX` || exit 1 exec strace -o $OUTPUT_TO ... /somewhere/else/yourscript "$@" 

where ... is whatever other strace arguments you need.

As an alternative, consider sysdig, as it can trace by filename or username without the need for a process ID or wrapper script.