- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Killing Hung Process
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2004 10:57 AM
08-25-2004 10:57 AM
Killing Hung Process
We have a monitoring script (which will run at every 30 Seconds), we will check for a java process.
If the process is present, the script will take the elapsed time for the process from the "ps -ef" output. The logic is if the process's elapsed time is more than specified time, the script will kill the process. We observed that the elapsed time of hanging process is not incrementing as expected. ( Its different than what we observed while testing using the dummy hanging process). So the process is getting killed after long hours( 3 hours
last time instead of 5 minutes).
Could someone Let me know the best method to identify a hanging process and kill it. ps -ef and picking the elapsed time is not working. Any other
ideas?
Thanks in advance,
Best Regards
Brian.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2004 02:13 PM - last edited on 07-07-2022 03:51 AM by Sunitha_Mod
08-25-2004 02:13 PM - last edited on 07-07-2022 03:51 AM by Sunitha_Mod
Re: Killing Hung Process
Hi Brian,
You could use the pstat_getproc() call and examine the pst_start field. This field contains the time the process started displayed in seconds since epoch. You could monitor this field and when it gets above a certain value you could send a signal to the process to terminate it.
The man page for pstat(2) contains several examples of calling pstat_getproc().
Regards,
Dave
I work at HPE
HPE Support Center offers support for your HPE services and products when and how you need it. Get started with HPE Support Center today.
[Any personal opinions expressed are mine, and not official statements on behalf of Hewlett Packard Enterprise]

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2004 02:22 PM
08-25-2004 02:22 PM
Re: Killing Hung Process
So you mean we are using a shell script now and i can use those commands inside the script? Could you pl. provide an example?
Thanks
Brian.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2004 02:31 PM
08-25-2004 02:31 PM
Re: Killing Hung Process
No, these are C programming functions, not K-shell functions. The approach I'm suggesting is to use a C program to call pstat_getproc() and look at one of the fields.
Are you restricted to using shell programming for this task or is C a possibility?
Regards,
Dave
I work at HPE
HPE Support Center offers support for your HPE services and products when and how you need it. Get started with HPE Support Center today.
[Any personal opinions expressed are mine, and not official statements on behalf of Hewlett Packard Enterprise]

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2004 02:43 PM
08-25-2004 02:43 PM
Re: Killing Hung Process
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2004 07:21 PM
08-25-2004 07:21 PM
Re: Killing Hung Process
if you don't want to use the pstat* syscall functions from the libc there is yet another display format of the ps command that you could choose when setting the socalled XPG4 environment through UNIX95.
The etime option displays the elapsed time of a process rather than a date like stime for log running processes.
e.g.
$ UNIX95= ps -e -o comm= -o etime=
grep from the comm field the process you need to monitor and parse the 2nd field.
Somewhere in between C system programming and scripting falls Perl.
If you can reconcile with Perl there is an excellent module on CPAN that gives full access to the pstat* syscalls.
Look here for Proc::ProcessTable
http://www.cpan.org/modules/by-module/Proc/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-26-2004 08:32 PM
08-26-2004 08:32 PM
Re: Killing Hung Process
A couple of observations that haven't been made yet.
The TIME field in the 'ps -ef' output is the cumulative amount of CPU used, not the elapsed time of the process, so it's not a surprise that it's not incremented for a hanging process (one that's not using any CPU).
Using Ralph's suggeestion of using the UNIX95 options looks the simplest way to get what you want, but you'll need to include the PID field too, if you want to be able to kill the process:
UNIX95= ps -e -o comm= -o etime= -o pid=
Writing a C program and looking at the pst_start field would work, but what you'd be doing is monitoring the difference between the value for that process and the current time; the start time itself is not going to change.
Andrew
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-27-2004 01:24 AM
08-27-2004 01:24 AM
Re: Killing Hung Process
UNIX95= ps -e -x -o pid,ppid,flags,state,etime,args
NOTE: -x is only functional on a patched system and mandatory for JavaJunk(tm) due to the massively long command lines and pathnames. The flags and state columns can be useful to toss at the programmers to fix the hanging code. You can also tell ps to list all processes with a specific name and never use grep. Change -e to -C name as in:
UNIX95= ps -C java -x -o pid,ppid,flags,state,etime,args
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2005 05:06 PM
06-01-2005 05:06 PM
Re: Killing Hung Process
I am facing same problem related to ioscan hung. If I rerun the ioscan,it get hung.
root 17667 1 0 May 30 ? 0:00 ioscan -fnC lan
root 17834 1 0 May 30 ? 0:00 ioscan -fn
root 17016 1 0 May 30 ? 0:00 ioscan -fnC lan
root 20464 1 0 May 30 ? 0:00 ioscan -fn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2005 07:19 PM
06-01-2005 07:19 PM
Re: Killing Hung Process
When you say 'hang', do you mean the process just doesn't complete, or that you can't kill it?
I think the best thing would be to open a new thread since this is a different topic.
Andrew
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2005 12:37 AM
06-02-2005 12:37 AM
Re: Killing Hung Process
what don't you want to kill these process?
i have never seen such a kind of;
root 17667 1 0 May 30 ? 0:00 ioscan -fnC lan
root 17834 1 0 May 30 ? 0:00 ioscan -fn
root 17016 1 0 May 30 ? 0:00 ioscan -fnC lan
root 20464 1 0 May 30 ? 0:00 ioscan -fn
also i would suggest you to check your syslog
&dmseg
because seems something is going wrong on your system :-(
Good Luck,