Solved

redirect thread dump to a new file

Posted on 2007-03-19
7
3,312 Views
Last Modified: 2012-06-27
hi,

how can i send kill -3 PID result to a new file. it goes my nohup.file and it is difficult to trace it.

thanks in advance...
0
Comment
Question by:ysnky
  • 3
  • 3
7 Comments
 
LVL 38

Expert Comment

by:yuzh
ID: 18753219
kill -3 PID  > /path-to/myfile 2>&1
0
 
LVL 27

Expert Comment

by:Nopius
ID: 18754528
ysnky, do you mean your process redirects it's output to nohup.out when you send SIGQUIT to it?
I see no way to redirect output then. Output is already redirected to 'nohup.out' (which is probably done 'nohup' command).

Or you just need to redirect the output of 'kill' command? In this case I agree with yuzh.

Or provide more details of what do you want.
0
 
LVL 9

Author Comment

by:ysnky
ID: 18754659
> Output is already redirected to 'nohup.out' (which is probably done 'nohup' command).

yes my application is started with nohup and my all outputs are sent to nohup.out. i dont would like to change it, i would like that while it is sending out to nohup.out, to send thread dump to another file bacause it sends nohup.out default and it is very difficult to trace it.

is it possbile?

0
Independent Software Vendors: 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!

 
LVL 27

Expert Comment

by:Nopius
ID: 18755552
So, your application is mulithreaded or forks childs.
They all write to the same file descriptor (I mean stdout and stderr, that goes to the same nohup.out). And there is no way to split that output unless you rewrite that application.

If you start different applications, you may direct output to different files.

You may get separate output of all children with this command:

strace -ff -o nohup -t -e trace=write -e write=1,2 nohup /path/to/your/program

you will have separate files for each child, like 'nohup.$pid'. The output in 'nohup.out' still remains the same while in 'nohup' and 'nohup.$pid' you will get the output in hexdump and in ascii format.
0
 
LVL 9

Author Comment

by:ysnky
ID: 18805929
in this case it is inpossible to redirect the thread dump to a new file while because of i started with nohup and i directed all outputs to nohup.out?

0
 
LVL 27

Accepted Solution

by:
Nopius earned 50 total points
ID: 18806009
What OS are you running?
Thread is a separate process (with pid) or just a user-level thread withing the same process?
If thread is within the same process, there is no means to redirect it's output to a separate file, you must rewrite application to do separate output.
If thread is a 'child' with it's own pid, I proposed a solution above for Linux, without rewriting code.
0
 
LVL 9

Author Comment

by:ysnky
ID: 18813803
OS: sun solaris and HP Unix

just a user-level thread withing the same process


thanks guys...
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

Title # Comments Views Activity
Virtualizing TAPE on dual VIOS 3 117
AIX 5.x set up arrow to recall 11 64
What are recommended OS for exim mail server? 10 121
unix in java example 9 77
Hello fellow BSD lovers, I've created a patch process for patching openjdk6 for BSD (FreeBSD specifically), although I tried to keep all BSD versions in mind when creating my patch. Welcome to OpenJDK6 on BSD First let me start with a little …
Why Shell Scripting? Shell scripting is a powerful method of accessing UNIX systems and it is very flexible. Shell scripts are required when we want to execute a sequence of commands in Unix flavored operating systems. “Shell” is the command line i…
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.:

726 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