redirect thread dump to a new file

Posted on 2007-03-19
Last Modified: 2012-06-27

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...
Question by:ysnky
  • 3
  • 3
LVL 38

Expert Comment

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

Expert Comment

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.

Author Comment

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?

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

LVL 27

Expert Comment

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.

Author Comment

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?

LVL 27

Accepted Solution

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.

Author Comment

ID: 18813803
OS: sun solaris and HP Unix

just a user-level thread withing the same process

thanks guys...

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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 …
FreeBSD on EC2 FreeBSD ( is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
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 get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…

708 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

15 Experts available now in Live!

Get 1:1 Help Now