- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: scripts to kill running process longer than 15...
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
07-17-2008 12:56 AM
07-17-2008 12:56 AM
I want to kill process which running longer than 15 minuts. Please give me a sample or existed scripts for me. Appreciatively.
Best Regards
Eric
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2008 01:14 AM
07-17-2008 01:14 AM
Re: scripts to kill running process longer than 15 minuts
This will list all root processes with their times:
$ UNIX95=1 ps -u root -opid= -otime=
0 01:48:55
8 00:00
874 1-01:24:52
(Example only: don't kill root processes!)
You would need to remove all times with two colons. Times with one colon you would kill if the minutes were >= 15.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2008 01:16 AM
07-17-2008 01:16 AM
Re: scripts to kill running process longer than 15 minuts
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2008 01:25 AM
07-17-2008 01:25 AM
Re: scripts to kill running process longer than 15 minuts
UNIX95= ps -eo pid,time,args | grep -v grep | grep
while read a b c
do
sec=`echo $b |cut -c 4-5`
if [ $sec -gt 15 ]
then
kill $a
fi
done < /tmp/out
Kenan.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2008 01:39 AM
07-17-2008 01:39 AM
Re: scripts to kill running process longer than 15 minuts
Appreciate both of your great help.
I try it.
Best Regards
Eric
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2008 01:45 AM
07-17-2008 01:45 AM
SolutionIf you are happy with our answers, please read the following about assigning points:
http://forums.itrc.hp.com/service/forums/helptips.do?#33
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2008 06:53 AM
07-20-2008 06:53 AM
Re: scripts to kill running process longer than 15 minuts
UNIX95= ps -eo pid,time,args | grep -v grep | grep
Above command, i dont understand the ' grep -v grep | grep '.
Would you kindly explain the meaning of it for me ? Thanks a lot.
BR
eric
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2008 07:41 AM
07-20-2008 07:41 AM
Re: scripts to kill running process longer than 15 minuts
> i dont understand the 'grep -v grep | grep
This simply eliminates the 'grep' process from the list of processes you want returned. The 'v' switch means exclude anything that matches.
Using 'grep' to find processes to kill is dangerous. You are not guaranteed to match only what you think. Using the UNIX95 (XPG4) mode of 'ps' allows you to *exactly* match with the '-C' argument.
For example, if we want to look for processes whose name is "mything" or "yourthing" we can do:
# UNIX95= ps -o pid,time,args -C mything -C yourthing
Note that I dropped the '-e' from the 'ps' switches and added '-C mything' and '-C yourthing'.
Notice, too, that the UNIX95= has whitespace following the equal symbol and no semicolon before the 'ps' command. This confines the UNIX95 behavior only to the command line. You don't want to set that mode unless you know what affect it will have.
If you want to eliminate the heading that comes with the 'ps' output, modify the above to:
# UNIX95= ps -o pid= -o time= -o args= -C mything -C yourthing
The "=" symbol after each '-o' argument suppresses that argument's name from any heading line --- quite useful.
See the 'ps' manpages for more information.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2008 12:45 PM
07-20-2008 12:45 PM
Re: scripts to kill running process longer than 15 minuts
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2008 05:09 PM
07-20-2008 05:09 PM
Re: scripts to kill running process longer than 15 minuts
I've started saying to use UNIX95=1 so nobody gets confused about the whitespace. (Of course the semicolon is another matter.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2008 06:56 PM
07-21-2008 06:56 PM
Re: scripts to kill running process longer than 15 minuts
Yes, thank in advance for all of your kind suggestion. I will use it carefully.
Best Regards
Eric