IBM Support

How to use the truss command to capture data for a failing command

Question & Answer


Question

How can I determine what is causing my command to fail?

Answer

Some root causes for command failures include: 
  • Permissions
  • Environment variables
  • Missing files
Truss data might provide clues about root causes for unexpected command behavior.
This example demonstrates how to use truss to trace the calls when userA runs a command.
  • The truss is run for userA's login shell. 
    • userA can be any user, including root.
-----------------------------------------------------------------------
1) Start "Terminal Session A" (Log in as userA)
-----------------------------------------------------------------------
Get current shell.
$ echo $$
  --> 7143448  (Example)
To confirm this is the parent ksh process for the truss, use the following command:
$ tty
  --> /dev/pts/3
$ ps -ef | grep "pts/3" | grep "$$" | grep ksh | grep -v grep
  -->> userA 7143448 4063484   0 17:54:23  pts/3  0:00 -ksh
-----------------------------------------------------------------------
2) Start "Terminal Session B" (Log in as root)
-----------------------------------------------------------------------
Start a truss of the userA login shell
#   truss -t\!lseek,\!_sigaction,\!kioctl -r all -w all -feado   /tmp/TSnnnnnnnnn.truss.out -p <PID from #1>
Note: the "-rALL" and "-wALL " flags include the full content of the I/O buffer for each read or write. You can omit these flags if you do not need to see the full content.  The default output will show the first 12 bytes of each read or write.
-----------------------------------------------------------------------
3) Return to "Terminal Session A" (Still logged in as userA)
-----------------------------------------------------------------------
Invoke the failing command.
$ <normal command syntax>
$ exit
$ .....Connection to <hostname> closed
-----------------------------------------------------------------------
4) Return to "Terminal Session B (Still logged in as root)
-----------------------------------------------------------------------
The truss exited when the userA ksh process ended.
You can examine /tmp/TSnnnnnnnnn.truss.out for errors.
The following errors might be listed if underlying files or commands fail to load:
8192252: 11599891: 3.0512: execve("/tmp/testsh", 0x0000000110063F70, 0x0000000110045150) Err#8  ENOEXEC
Or:
8192252: 11599891: 3.4349: kopen("/tmp/profile", O_RDONLY) Err#13 EACCES
In the following example, invalid data is generated because the user's LANG was changed by an underlying script. We can see the script sources /tmp/profileA. The profileA file changes the Japanese UTF-8 LANG to a different Japanese encoding.
7864392: 12189719:  envp: ODMDIR=/etc/objrepos LANG=JA_JP
7995548: 15007961: 2.5649:        kopen("/tmp/profileA", O_RDONLY) = 3
7995548:           e x p o r t   L A N G = J a _ J P\n
If you still need AIX Support analysis, provide complete details about the failure, and upload  /tmp/TSnnnnnnnnn.truss.out or attach to your case.
SUPPORT

If you require more assistance, use the following step-by-step instructions to contact IBM to open a case for software with an active and valid support contract.  

1. Document (or collect screen captures of) all symptoms, errors, and messages related to your issue.

2. Capture any logs or data relevant to the situation.

3. Contact IBM to open a case:

   -For electronic support, see the IBM Support Community:
     https://www.ibm.com/mysupport
   -If you require telephone support, see the web page:
      https://www.ibm.com/planetwide/

4. Provide a clear, concise description of the issue.

 - For guidance, see: Working with IBM AIX Support: Describing the problem.

5. If the system is accessible, collect a system snap, and upload all of the details and data for your case.

 - For guidance, see: Working with IBM AIX Support: Collecting snap data

[{"Type":"MASTER","Line of Business":{"code":"LOB08","label":"Cognitive Systems"},"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"SWG10","label":"AIX"},"ARM Category":[{"code":"a8m0z000000cvzgAAA","label":"Commands"}],"ARM Case Number":"","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"All Versions"}]

Document Information

Modified date:
28 February 2022

UID

ibm16560128