LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-09-2015, 07:51 PM   #1
gdizzle
Member
 
Registered: Jul 2012
Posts: 234

Rep: Reputation: Disabled
kill -3 pid > /tmp/process.txt not working?


Hi All,
I am trying to get a dump of a process using kill and it doesn't look to be working, can someone explain what I am doing wrong?

Code:
systemctl start snmpd.service
Code:
pgrep snmpd
4233
Code:
kill -3 4233 > /tmp/snmp_pid.txt
OR

Code:
kill -SIGQUIT 4233 > /tmp/snmp_pid.txt
Yes the process quit's which is fine but there is no output from the process in /tmp/snmp_pid.txt.

Can someone please explain?

Thanks
 
Old 04-09-2015, 11:58 PM   #2
veerain
Senior Member
 
Registered: Mar 2005
Location: Earth bound to Helios
Distribution: Custom
Posts: 2,524

Rep: Reputation: 319Reputation: 319Reputation: 319Reputation: 319
The kill command justs send a signal to process. It's upto the process to produce some messages.
 
Old 04-10-2015, 12:31 AM   #3
gdizzle
Member
 
Registered: Jul 2012
Posts: 234

Original Poster
Rep: Reputation: Disabled
Can I get a process where this would be a good example? Or is JAVA the only one from what I can see online?
 
Old 04-10-2015, 12:44 AM   #4
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 9,203

Rep: Reputation: 2675Reputation: 2675Reputation: 2675Reputation: 2675Reputation: 2675Reputation: 2675Reputation: 2675Reputation: 2675Reputation: 2675Reputation: 2675Reputation: 2675
what do you expect? what should be put into that file?
 
Old 04-10-2015, 12:48 AM   #5
gdizzle
Member
 
Registered: Jul 2012
Posts: 234

Original Poster
Rep: Reputation: Disabled
Thats what I wish to see pan64 an example of what's in there? How it's used for debugging.

I understand different applications would have different results. Show me an example.
 
Old 04-10-2015, 12:50 AM   #6
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 9,203

Rep: Reputation: 2675Reputation: 2675Reputation: 2675Reputation: 2675Reputation: 2675Reputation: 2675Reputation: 2675Reputation: 2675Reputation: 2675Reputation: 2675Reputation: 2675
In general nothing. That construct is not useful at all (but obviously it is only my own opinion). That's why I asked.
 
Old 04-10-2015, 12:52 AM   #7
gdizzle
Member
 
Registered: Jul 2012
Posts: 234

Original Poster
Rep: Reputation: Disabled
Can someone show me an example, I cannot find an application that replies to kill -3 ?
 
Old 04-10-2015, 01:30 AM   #8
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,353
Blog Entries: 55

Rep: Reputation: 3541Reputation: 3541Reputation: 3541Reputation: 3541Reputation: 3541Reputation: 3541Reputation: 3541Reputation: 3541Reputation: 3541Reputation: 3541Reputation: 3541
No idea what you're trying to troubleshoot exactly but if you're not suspecting trouble with systemd itself, why not configure the process for debug / verbose mode, start the process with 'strace' (see 'man strace') from the command line redirecting output to text files, then kill it and then look at its log file and strace logs?
 
Old 04-10-2015, 01:45 AM   #9
gdizzle
Member
 
Registered: Jul 2012
Posts: 234

Original Poster
Rep: Reputation: Disabled
I have a rouge java process running wild, http://javaeesupportpatterns.blogspo...-high-cpu.html, I have tested on my other servers which run WAS kill -3 and I had no process dumps, I have also tested other applications for kill -3, hoping to get an idea of what the output should look like so I can debug it as explained in the article.


I will eventually kill the process, but I was after a process dump for output, I could install jstack and other tools but, things get "political" so I am trying to use the current tools on the troublesome system.

It would be nice to use kill -3, for it but looks like the application does not respond to it..., would be good but nobody can replicate the issue hence why I am leaving this thing running until I can guarantee i get decent output. The application has been running since January and nobody noticed it and the logs have been rotated long ago.

I have looked inside the pid / child pid for more information but cmdline output cannot be decoded into which webcontainer id hence I was looking into the article pasted.

In the meantime I thought I would give kill -3 a try as I have never used it or seen it work.

will look deeper into strace.
 
Old 04-10-2015, 02:05 AM   #10
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 9,203

Rep: Reputation: 2675Reputation: 2675Reputation: 2675Reputation: 2675Reputation: 2675Reputation: 2675Reputation: 2675Reputation: 2675Reputation: 2675Reputation: 2675Reputation: 2675
It seems you think kill -3 will produce a core. But actually kill itself does not do that, it only sends the signal to the process. The core probably will be created, by the kernel, and not the kill command itself. You are not able to specify the location of the core file by that redirection.
That's why I asked you to explain what do you really expect. Is that a core file?
 
Old 04-10-2015, 04:26 PM   #11
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,688

Rep: Reputation: 1259Reputation: 1259Reputation: 1259Reputation: 1259Reputation: 1259Reputation: 1259Reputation: 1259Reputation: 1259Reputation: 1259
If you are expecting to get a core dump of the process, that is NOT the way to do it.

First the process must be running with ulimits that permit a dump to be created (see man page on ulimit, normally core dumps are disabled).

Second, when the signal is given to the process, a core dump will be written... if and only if the working directory is writable by the process. I believe the usual name is Core.<pid> (uppercase C, but it has been a while).

For a Java program, a core dump is not that useful - the information in it is more related to the JVM, and tracing out what the application was doing in the first place gets tricky. Normally such debugging would be done through an IDE such as Eclipse. Of course, if you are debugging the JVM I suspect otherwise, but am now out of my depth.
 
Old 04-12-2015, 06:20 PM   #12
gdizzle
Member
 
Registered: Jul 2012
Posts: 234

Original Poster
Rep: Reputation: Disabled
I am after a Thread Dump as specified here : http://javaeesupportpatterns.blogspo...-high-cpu.html

Point 2, generate a thread dump, using kill -3.

core dump: a dump of the contents of main memory, carried out typically as an aid to debugging.

thread dump: is a list of all the Java threads that are currently active in a Java Virtual Machine (JVM).

- As explained here:

http://stackoverflow.com/questions/1...of-thread-dump

Now thread dumps should be able to be made with
Code:
kill -3 pid > thread_dump.txt
or
Code:
 kill -s SIGQUIT pid > thread_dump.txt

Nothing specified here from Redhat about the Ulimits, so I am thinking the core dumps, (memory) are specified different from thread dumps.

https://access.redhat.com/solutions/18178


I haven't seen a thread dump yet, with kill has someone got this working?

looks like jstack might be the option.
 
Old 04-13-2015, 12:21 AM   #13
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 9,203

Rep: Reputation: 2675Reputation: 2675Reputation: 2675Reputation: 2675Reputation: 2675Reputation: 2675Reputation: 2675Reputation: 2675Reputation: 2675Reputation: 2675Reputation: 2675
Based on the link you posted this is a special feature of jvm (to produce a thread dump on kill -3). It was also mentioned dump is put into a logfile or in a separate file. That is defined by the jvm, and you cannot specify the output using the kill command.
You can try strace -f strace.log <your java app>, execute kill -3 and check that log. You will need to find to location of the dump in that strace.log
 
Old 04-13-2015, 01:15 AM   #14
gdizzle
Member
 
Registered: Jul 2012
Posts: 234

Original Poster
Rep: Reputation: Disabled
Thanks Pan, this looks like a closer win to seeing whats going on.

Code:
strace -f -p 14324 -o /tmp/java_pid.txt
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Can I assign a Command to a specific PID so I can kill a predetermined PID johnmccarthy Linux - Newbie 1 11-03-2011 08:41 AM
[SOLVED] how to read a PID from a text file and kill the corresponding process sneakyimp Linux - Newbie 3 06-30-2010 01:52 PM
Kill child process problem. No matter what i try cant stop pid becoming a zombie?? ajb181 Linux - Software 1 11-15-2009 05:36 PM
How to get the PID of the process giving kill signal to a process? hariprd Programming 2 11-27-2008 03:10 AM
Looking for a way to find a PID and kill the process it belongs to johngreenwood Programming 6 01-14-2007 05:45 AM


All times are GMT -5. The time now is 06:18 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration