[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3508
  • Last Modified:

redirect thread dump to a new file

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
ysnky
Asked:
ysnky
  • 3
  • 3
1 Solution
 
yuzhCommented:
kill -3 PID  > /path-to/myfile 2>&1
0
 
NopiusCommented:
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
 
ysnkyAuthor Commented:
> 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
NopiusCommented:
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
 
ysnkyAuthor Commented:
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
 
NopiusCommented:
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
 
ysnkyAuthor Commented:
OS: sun solaris and HP Unix

just a user-level thread withing the same process


thanks guys...
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now