Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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..
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.
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.
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.
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
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)
==> 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.
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.
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
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 ?
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.
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..
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.