- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- script for terminate dead 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
05-17-2005 09:34 PM
05-17-2005 09:34 PM
I am looking for to have a script that can kill the process - the process owner is cronusr and it is idle for one hour ( I think it can check by ps -aux |grep pid , if the status is R , then it is running , if it is S , then it is sleep and the process can be termiated ) , could suggest the script for the case ? thx in advance.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2005 09:59 PM
05-17-2005 09:59 PM
SolutionProbably you'll need to set UNIX95=1 env variable, to enable XPG4 with more options.
Then parse the output of ps with grep/awk etc, get PID and kill that proccess.
If you'll post here the sample of ps output that you are interested to parse, I can suggest a few things, because from the info you supplied I doubt that I can give you proper "ps" line, so it won't kill some important things ;)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2005 10:00 PM
05-17-2005 10:00 PM
Re: script for terminate dead process
for pid in `ps -el -u cronuser | awk '{ if ( $2 == "S") { print $4 }}'`
do
kill -9 $pid
done
hth.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2005 10:13 PM
05-17-2005 10:13 PM
Re: script for terminate dead process
It is easier to find process "elapsed" time rather than idle time, so for example if you know your process should never take more than 2 hours you could use: -
UNIX95= ps -o pid,etime -u cronusr
This will show you the PID and elapsed time for every process of cronusr. From this you can determine which ones have run >2 hours and kill as necessary.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2005 10:48 PM
05-17-2005 10:48 PM
Re: script for terminate dead process
Wouldn't it be easier to fix the problem rather than create another process to monitor the one that has issues with it?
It's like nuking the planet to save the whales - over kill.
live free or die
harry d brown jr