Solved

Truss on process to check the files referenced by it.

Posted on 2008-10-18
8
778 Views
Last Modified: 2013-12-27
How do i run truss on a process id to check the files opened by it on solaris 10?

I am looking for an output like below..





/16:    stat64("/usr/share/webconsole/webapps/console/WEB-INF/web.xml", 0xE637E938) = 0

/16:    access("/usr/share/webconsole/webapps/console/WEB-INF/web.xml", R_OK) = 0

/16:    stat64("/usr/share/webconsole/webapps/console/WEB-INF/web.xml", 0xE637E998) = 0

/16:    stat64("/usr/share/webconsole/webapps/console/WEB-INF/web.xml", 0xE637E9A8) = 0

/16:    stat64("/usr/share/webconsole/webapps/console/WEB-INF", 0xE637E938) = 0

/16:    access("/usr/share/webconsole/webapps/console/WEB-INF", R_OK) = 0

/16:    stat64("/usr/share/webconsole/webapps/console/WEB-INF", 0xE637E998) = 0
0
Comment
Question by:p0sreed
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
8 Comments
 
LVL 6

Expert Comment

by:wwnosal
ID: 22747721
Depening if you have it installed lsof -p pid might be a bit nicer to read

0
 

Author Comment

by:p0sreed
ID: 22761597
We don't have lsof installed on all the boxes.

I am looking for the similar output as in my example.
0
 
LVL 22

Expert Comment

by:blu
ID: 22965355
I am not sure if you are asking to monitor new files being opened or old files that are already opened. If the former, then truss will do it, just as you showed above. If the latter, then you should use the pfiles command. If there is something else in addition I don't understand, then please let me know
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:p0sreed
ID: 22965415
I am talking about new files being opened.

what is the proper truss command to produce the output that i pasted in my first post.
0
 
LVL 22

Expert Comment

by:blu
ID: 22966409
Okay, one more question. In your example, your show only access and stat64 lines. Do you want only those two, or any syscall that touches a file by filename?

For the former, you want this:

truss -l -taccess,stat64 -s!all -p pid

You might want to try adding stat and lstat to the above list, depending on your purpose.

However, if you want to catch any file, then you need to add a bunch more syscalls to the above  list.
0
 

Author Comment

by:p0sreed
ID: 22974258
root@clyde:/ # truss -l -taccess,stat64 -s!all -p 558
bash: !all: event not found
root@clyde:/ #

0
 
LVL 22

Accepted Solution

by:
blu earned 500 total points
ID: 22975033
You are using the c-shell, which uses the ! character as the history substitution character. Either use a different shell or escape the ! with a backslash:

truss -l -taccess,stat64 -s\!all -p 558
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Installing FreeBSD… FreeBSD is a darling of an operating system. The stability and usability make it a clear choice for servers and desktops (for the cunning). Savvy?  The Ports collection makes available every popular FOSS application and packag…
I promised to write further about my project, and here I am.  First, I needed to setup the Primary Server.  You can read how in this article: Setup FreeBSD Server with full HDD encryption (http://www.experts-exchange.com/OS/Unix/BSD/FreeBSD/A_3660-S…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question