Solved

redirect thread dump to a new file

Posted on 2007-03-19
7
3,216 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Can I copy a solaris 10 Install DVD to local hard drive and install from there?  How? 21 154
LastLogonTimeStamp Attribute 7 48
NTP Server in VMware 5 160
unix in java example 9 52
Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
My previous tech tip, Installing the Solaris OS From the Flash Archive On a Tape (http://www.experts-exchange.com/articles/OS/Unix/Solaris/Installing-the-Solaris-OS-From-the-Flash-Archive-on-a-Tape.html), discussed installing the Solaris Operating S…
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.:
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

914 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now