Patrick-Dussault

Strace and Truss :: get debug logs and system calls in 1 command

Blog Post created by Patrick-Dussault Employee on Nov 7, 2016

How to make shell script in debug and get all debug log in a file and trace all system calls and
signals.

 

Here's 2 command lines to gather all debug logs with system calls for troubleshooting an installer, configurator or stop and start scripts on Unix / Linux

 

These samples are for the Policy Server "stop-all" command :

 

Unix :

 

/ * make a security copy * /

 

  # cp -p stop-all stop-all.orig

 

/ * set the shell script to debug * /

 

  # vi stop-all

 

   add :
   Modify the script ./stop-all and add "set -x" on the line
   right after the shebang like this :

 

   #!/bin/sh
   set -x

 

/ * Run the shell command script wrapped with truss command * /

 

  # truss –adefl –o output.txt ./stop-all > runstop.txt 2>&1

 

Gather output.txt and runstop.txt for the traces.

 

Linux :

 

/ * make a security copy * /

 

   # cp -p stop-all stop-all.orig

 

/ * set the shell script to debug * /

 

   # nano -w stop-all

 

    add :
    Modify the script ./stop-all and add "set -x" on the line
    right after the shebang like this :

 

    #!/bin/sh
    set -x

 

# strace -o run.dump -t -ff ./stop-all > run-output.txt 2>&1

 

Gather all run.dump* and run-output.txt for the traces.

Outcomes