LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 04-25-2008, 12:06 PM   #1
jbilla
LQ Newbie
 
Registered: Apr 2008
Posts: 19

Rep: Reputation: 0
How to check Process hung or not???


Hello friends...

I want to know how can I check if the ( currently running one )process is hung or not? Is there any command or something that I can check the running/hang status?

What I know is from "ps auxww |grep 'process_ID' " I can have current process' status like S (Sleep), R (Running) , Z (zombie) etc.. But my question is how can I check if the process is running or not..

Can I get something from output?
[root@server blah/blah]# cat /proc/2324/status
Name: kmpathd/1
State: S (sleeping)
SleepAVG: 98%
Tgid: 2324
Pid: 2324
PPid: 13
TracerPid: 0
Uid: 0 0 0 0
Gid: 0 0 0 0
FDSize: 32
Groups:
Threads: 1
SigPnd: 0000000000000000
ShdPnd: 0000000000000000
SigBlk: ffffffffffffffff
SigIgn: 0000000000010000
SigCgt: 0000000000000000
CapInh: 0000000000000000
CapPrm: 00000000ffffffff
CapEff: 00000000fffffeff

Please advise if you have any idea..

Thank you.
 
Old 04-25-2008, 12:42 PM   #2
{BBI}Nexus{BBI}
Senior Member
 
Registered: Jan 2005
Location: Nottingham, UK
Distribution: Mageia 6, KDE Neon
Posts: 4,313

Rep: Reputation: 212Reputation: 212Reputation: 212
I should think using top would be a way to check. Simply type: top.
 
Old 04-25-2008, 12:52 PM   #3
BrianK
Senior Member
 
Registered: Mar 2002
Location: Los Angeles, CA
Distribution: Debian, Ubuntu
Posts: 1,334

Rep: Reputation: 51
Quote:
Originally Posted by {BBI}Nexus{BBI} View Post
I should think using top would be a way to check. Simply type: top.
I would guess that if the OP knows advanced usage of ps & how to navigate the proc fs, he probably also knows of the existence of "top"
 
Old 04-25-2008, 01:00 PM   #4
{BBI}Nexus{BBI}
Senior Member
 
Registered: Jan 2005
Location: Nottingham, UK
Distribution: Mageia 6, KDE Neon
Posts: 4,313

Rep: Reputation: 212Reputation: 212Reputation: 212
Quote:
Originally Posted by BrianK View Post
I would guess that if the OP knows advanced usage of ps & how to navigate the proc fs, he probably also knows of the existence of "top"
I've assumed someone having prior knowledge of something before, only see another user suggest it and 'Hey Presto' the OP is a happy bunny again. At the very least, any newbies reading this thread will now know of tops existance. Point taken though.
 
Old 04-25-2008, 03:55 PM   #5
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 254Reputation: 254Reputation: 254
Is this process something you scripted or coded? Is it something else? Is there any type of interaction for this process to see if it's responding? More details get better replies.
 
Old 04-28-2008, 07:26 AM   #6
jbilla
LQ Newbie
 
Registered: Apr 2008
Posts: 19

Original Poster
Rep: Reputation: 0
Thanks for the reply

Quote:
I should think using top would be a way to check. Simply type: top.
==> But in Top command you will only see the time parameter that is changing and the process status here you see "S" i.e. Sleep.. and Nothing else. You will just see the process using too much resources that's it.

top - 08:15:27 up 227 days, 17:21, 14 users, load average: 0.06, 0.06, 0.04
Tasks: 644 total, 1 running, 643 sleeping, 0 stopped, 0 zombie
Cpu(s): 0.1% us, 0.4% sy, 0.0% ni, 99.5% id, 0.0% wa, 0.0% hi, 0.0% si
Mem: 16629704k total, 16475872k used, 153832k free, 361120k buffers
Swap: 8385920k total, 8k used, 8385912k free, 14840552k cached

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
6990 root 16 0 422m 108m 5892 S 0 0.7 70:15.21 java


Quote:
Originally Posted by trickykid View Post
Is this process something you scripted or coded? Is it something else? Is there any type of interaction for this process to see if it's responding? More details get better replies.
==> There isnt any script. I am talking about any process. There should be some way to check if the process is hung or not. If one process is using maximum resources and I would Like to see if that's running or not rather then restarting or reloading that by sending HUP signal and start the task again. (cause that would be overhead)

Any Idea? How to check if that's hung ?

Thanks for your replies..

Last edited by jbilla; 04-28-2008 at 07:31 AM.
 
Old 04-28-2008, 01:27 PM   #7
BrianK
Senior Member
 
Registered: Mar 2002
Location: Los Angeles, CA
Distribution: Debian, Ubuntu
Posts: 1,334

Rep: Reputation: 51
Quote:
Originally Posted by jbilla View Post
==> But in Top command you will only see the time parameter that is changing and the process status here you see "S" i.e. Sleep.. and Nothing else. You will just see the process using too much resources that's it.

top - 08:15:27 up 227 days, 17:21, 14 users, load average: 0.06, 0.06, 0.04
Tasks: 644 total, 1 running, 643 sleeping, 0 stopped, 0 zombie
Cpu(s): 0.1% us, 0.4% sy, 0.0% ni, 99.5% id, 0.0% wa, 0.0% hi, 0.0% si
Mem: 16629704k total, 16475872k used, 153832k free, 361120k buffers
Swap: 8385920k total, 8k used, 8385912k free, 14840552k cached

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
6990 root 16 0 422m 108m 5892 S 0 0.7 70:15.21 java




==> There isnt any script. I am talking about any process. There should be some way to check if the process is hung or not. If one process is using maximum resources and I would Like to see if that's running or not rather then restarting or reloading that by sending HUP signal and start the task again. (cause that would be overhead)

Any Idea? How to check if that's hung ?

Thanks for your replies..
Well what is your definition of "hung"? Certainly a process using 100% CPU for an extended amount of time does not necessarily mean that it's hung.
 
Old 04-29-2008, 06:03 AM   #8
jbilla
LQ Newbie
 
Registered: Apr 2008
Posts: 19

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by BrianK View Post
Well what is your definition of "hung"?
A process tries to read/write some file that's been modified now or deleted currently, a process thats waiting for some other event to occur that never occurs, a process thats transferring data from one server to other and suddenly some network issue occurs, process went into loop that never completes, etc
Quote:
Originally Posted by BrianK View Post
Certainly a process using 100% CPU for an extended amount of time does not necessarily mean that it's hung.
That's right but what if that process continues to use that much resources for more than half an hour? You will certainly like to know if that process is in running state or its hung, right ?
 
Old 04-29-2008, 01:51 PM   #9
BrianK
Senior Member
 
Registered: Mar 2002
Location: Los Angeles, CA
Distribution: Debian, Ubuntu
Posts: 1,334

Rep: Reputation: 51
Quote:
Originally Posted by jbilla View Post
A process tries to read/write some file that's been modified now or deleted currently, a process thats waiting for some other event to occur that never occurs, a process thats transferring data from one server to other and suddenly some network issue occurs, process went into loop that never completes, etc

That's right but what if that process continues to use that much resources for more than half an hour? You will certainly like to know if that process is in running state or its hung, right ?
I would love to know if a process is in a running state. I suppose this lies outside my realm of expertise, but I deal with many, many processes that run 100% CPU(s) for hours at a time & know of no way of determining the running state other than checking the logs of the processes in question.

This is not to say it's impossible, but it is to say I don't know how to do it & to raise the question of how one would actually determine if a process (that may or may not log) has gone into some infinite loop. The problem with determining if something is an infinite loop (as far as I know) lies in the fact that an infinite loop is a programming design flaw as opposed to an execution error, meaning that the program isn't doing anything illegal, in fact, it's doing exactly what it was told to do, unfortunately, it was told wrong.

This is an interesting thread. I hope something comes of it.

Last edited by BrianK; 04-29-2008 at 01:53 PM.
 
Old 05-02-2008, 07:38 AM   #10
jbilla
LQ Newbie
 
Registered: Apr 2008
Posts: 19

Original Poster
Rep: Reputation: 0
Anyone else have any idea about this?
 
Old 05-02-2008, 10:28 AM   #11
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,409
Blog Entries: 55

Rep: Reputation: 3582Reputation: 3582Reputation: 3582Reputation: 3582Reputation: 3582Reputation: 3582Reputation: 3582Reputation: 3582Reputation: 3582Reputation: 3582Reputation: 3582
If it's a specific application you use that hangs maybe you should cut the chase and just post details. Dunno. Could help.
 
Old 05-07-2008, 12:19 PM   #12
jbilla
LQ Newbie
 
Registered: Apr 2008
Posts: 19

Original Poster
Rep: Reputation: 0
Ok After searching for this from so many days I come to conclusion that the process status wit h "D" is hung process that you will get from ps auxww |grep "D" in status column.

Which later on move to "z" zombie process. See D and Z have difference. I AM and WAS not talking about zombie process earlier.. I was talking about Hung process. I got some idea about this from support.redhat.com's knowledge base..

what you guys think on this?

Last edited by jbilla; 05-08-2008 at 09:21 AM.
 
Old 05-07-2008, 12:36 PM   #13
BrianK
Senior Member
 
Registered: Mar 2002
Location: Los Angeles, CA
Distribution: Debian, Ubuntu
Posts: 1,334

Rep: Reputation: 51
Quote:
Originally Posted by jbilla View Post
Ok After searching for this from so many days I come to conclusion that the process status wit h "D" is hung process that you will get from ps auxww |grep "D" in status column.

Which letter on move to "z" zombie process. See D and Z have difference. I AM and WAS not talking about zombie process earlier.. I was talking about Hung process. I got some idea about this from support.redhat.com's knowledge base..

what you guys think on this?
As far as I know, a 'D' status from the ps command means that the process has made a request for IO & is waiting for a response AND cannot be interrupted while it waits. This *may* satisfy your definition of a hung process at least when it comes to waiting for an event that never occurs, but will not satisfy the infinite loop side of your definition of a hung process.

It's also very possible that a process could have a legitimate 'D' status without being hung.

edited to add: you can't kill a process with a 'D' status - as in, it's not possible. Doing so would leave the kernel in an inconsistent state which would lead to a panic, so it's usually not allowed. Don't know if that matters, but... food for thought.

Last edited by BrianK; 05-07-2008 at 12:49 PM.
 
Old 08-09-2010, 05:37 AM   #14
sudhi_naidu
LQ Newbie
 
Registered: Jun 2008
Posts: 7

Rep: Reputation: 0
Check if the process is hung or not

You can run "strace -p <process_ID>" command to check if the process is hung or not. If it is running it would issue system calls and based on what system call you can also determine if it is waiting for some IO or trying to read/write a file or waiting for some other child process.

I know its late response, but just wanted to share this info for someone else searching for similar requirement.
 
  


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
check process ust Linux - Software 5 03-05-2008 02:46 AM
System Hung Process Checking ahpin Linux - Server 2 08-15-2006 01:27 AM
killing a hung up process with a script lockejr Linux - General 2 04-13-2006 11:40 PM
Check the process sunhui Linux - Software 5 03-01-2006 07:07 AM
Boot gets hung up at Partition check veroth *BSD 4 10-06-2003 02:30 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 04:11 AM.

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