- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Kill command
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
Discussions
Discussions
Discussions
Forums
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
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
тАО10-25-2005 10:58 AM
тАО10-25-2005 10:58 AM
The application spawns connections and before backups we want to remove all of them quickly before stopping the application. they all look like this: (end with inserverD)
root 8730 1 0 12:29:13 ? 0:25 /inserver54_pro/bin/inserverD
This command below was tried without success, and may not even be close. I would be grateful for any help.
. kill ps auxww |grep inserverD |egrep -v grep |awk '{print $2}'
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-25-2005 11:10 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-25-2005 11:12 AM
тАО10-25-2005 11:12 AM
Re: Kill command
for i in $(ps auxww |grep inserverD |grep -v grep |awk '{print $2}')
do
kill ${i}
done
If the application spawns these connections, shouldn't the application be cleaning them up?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-25-2005 11:20 AM
тАО10-25-2005 11:20 AM
Re: Kill command
Try this.,
#ps -ef|grep -i inserverD|awk '{print $2)'|xargs kill -9
Cheers.!!Granite
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-26-2005 07:58 PM
тАО10-26-2005 07:58 PM
Re: Kill command
try your command with little chanhges:
kill -9 $(ps auxww |grep [i]nserverD awk '{print $2}')
-9 to be sure to kill the process
$() to execute fisrt the ps command and apply the kill -9 to the result
grep [i] to avoid grep -v grep
HTH
Art
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-26-2005 08:13 PM
тАО10-26-2005 08:13 PM
Re: Kill command
ps -ef|grep abc
Will match following (assuming there are processe like abc, abcd, dhbabc etc)
UNIX95= ps -C"command" -o pid=|xargs kill -15
No kill -9, it is bad sysadmin.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-26-2005 08:19 PM
тАО10-26-2005 08:19 PM
Re: Kill command
kill
To suite your application,
kill -9 `ps -u root -ef | grep -i inserverd | grep -v grep | awk '{ print $2 }'`
pid=$(ps -u root -ef | grep -i inserverd | grep -v grep | awk '{ print $2 }')
[[ ! -z ${pid} ]] && kill -9 ${pid}
-Muthu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-26-2005 08:33 PM
тАО10-26-2005 08:33 PM
Re: Kill command
I never write that grep is a bad idea I just improve teh command reducing its complexity.
i.e:
1]. giving only | grep ora_ you see in teh output also the grep command itself:
10:29 GPOP09BN hpbbnn1/home/oracle/> ps -fu oracle|grep ora_
oracle 22714 1 0 Oct 22 ? 1:28 ora_ckpt_BUS01BX
oracle 22708 1 0 Oct 22 ? 0:54 ora_pmon_BUS01BX
oracle 22720 1 0 Oct 22 ? 0:44 ora_cjq0_BUS01BX
oracle 22716 1 0 Oct 22 ? 0:36 ora_smon_BUS01BX
oracle 22718 1 0 Oct 22 ? 0:00 ora_reco_BUS01BX
oracle 20782 1 0 Oct 22 ? 2:20 ora_ckpt_GPOP09BN
oracle 20790 1 0 Oct 22 ? 0:12 ora_arc0_GPOP09BN
oracle 20780 1 0 Oct 22 ? 1:38 ora_lgwr_GPOP09BN
oracle 20778 1 0 Oct 22 ? 3:52 ora_dbw0_GPOP09BN
oracle 20784 1 0 Oct 22 ? 0:39 ora_smon_GPOP09BN
oracle 20788 1 0 Oct 22 ? 0:43 ora_cjq0_GPOP09BN
oracle 20786 1 0 Oct 22 ? 0:00 ora_reco_GPOP09BN
oracle 22712 1 0 Oct 22 ? 6:06 ora_lgwr_BUS01BX
oracle 22710 1 0 Oct 22 ? 35:54 ora_dbw0_BUS01BX
oracle 20776 1 0 Oct 22 ? 2:25 ora_pmon_GPOP09BN
oracle 20792 1 0 Oct 22 ? 0:08 ora_arc1_GPOP09BN
oracle 29610 29568 1 10:29:46 pts/ta 0:00 grep ora_
2]. to remove the grep command is needed another grep command: grep -v grep:
10:29 GPOP09BN hpbbnn1/home/oracle/> ps -fu oracle|grep ora_|grep -v grep
oracle 22714 1 0 Oct 22 ? 1:28 ora_ckpt_BUS01BX
oracle 22708 1 0 Oct 22 ? 0:54 ora_pmon_BUS01BX oracle 22720 1 0 Oct 22 ? 0:44 ora_cjq0_BUS01BX
oracle 22716 1 0 Oct 22 ? 0:36 ora_smon_BUS01BX
oracle 22718 1 0 Oct 22 ? 0:00 ora_reco_BUS01BX
oracle 20782 1 0 Oct 22 ? 2:20 ora_ckpt_GPOP09BN
oracle 20790 1 0 Oct 22 ? 0:12 ora_arc0_GPOP09BN
oracle 20780 1 0 Oct 22 ? 1:38 ora_lgwr_GPOP09BN
oracle 20778 1 0 Oct 22 ? 3:52 ora_dbw0_GPOP09BN
oracle 20784 1 0 Oct 22 ? 0:39 ora_smon_GPOP09BN
oracle 20788 1 0 Oct 22 ? 0:43 ora_cjq0_GPOP09BN
oracle 20786 1 0 Oct 22 ? 0:00 ora_reco_GPOP09BN
oracle 22712 1 0 Oct 22 ? 6:06 ora_lgwr_BUS01BX
oracle 22710 1 0 Oct 22 ? 35:54 ora_dbw0_BUS01BX
oracle 20776 1 0 Oct 22 ? 2:25 ora_pmon_GPOP09BN
oracle 20792 1 0 Oct 22 ? 0:08 ora_arc1_GPOP09BN
3]. or more simply you can use grep [o]ra_
to got your result without including grep in the output list. (man grep (regular expression) for further info):
10:30 GPOP09BN hpbbnn1/home/oracle/> ps -fu oracle|grep [o]ra_
oracle 22714 1 0 Oct 22 ? 1:28 ora_ckpt_BUS01BX
oracle 22708 1 0 Oct 22 ? 0:54 ora_pmon_BUS01BX
oracle 22720 1 0 Oct 22 ? 0:44 ora_cjq0_BUS01BX
oracle 22716 1 0 Oct 22 ? 0:36 ora_smon_BUS01BX
oracle 22718 1 0 Oct 22 ? 0:00 ora_reco_BUS01BX
oracle 20782 1 0 Oct 22 ? 2:20 ora_ckpt_GPOP09BN
oracle 20790 1 0 Oct 22 ? 0:12 ora_arc0_GPOP09BN
oracle 20780 1 0 Oct 22 ? 1:38 ora_lgwr_GPOP09BN
oracle 20778 1 0 Oct 22 ? 3:52 ora_dbw0_GPOP09BN
oracle 20784 1 0 Oct 22 ? 0:39 ora_smon_GPOP09BN
oracle 20788 1 0 Oct 22 ? 0:43 ora_cjq0_GPOP09BN
oracle 20786 1 0 Oct 22 ? 0:00 ora_reco_GPOP09BN
oracle 22712 1 0 Oct 22 ? 6:06 ora_lgwr_BUS01BX
oracle 22710 1 0 Oct 22 ? 35:54 ora_dbw0_BUS01BX
oracle 20776 1 0 Oct 22 ? 2:25 ora_pmon_GPOP09BN
oracle 20792 1 0 Oct 22 ? 0:08 ora_arc1_GPOP09BN
10:30 GPOP09BN hpbbnn1/home/oracle/>
That's all folk.
Art
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-26-2005 10:06 PM
тАО10-26-2005 10:06 PM
Re: Kill command
2) ps -fu oracle|grep [o]ra_
I hope you may not get same for this too at all.
grep is using matching regexp's.
[o]ra_ or ora_ is same. You will get grep ora_ process in process list. If you are selecting all process then,
# ps -efu oracle |grep -v grep | grep
If you know full string then,
# UNIX95= ps -fu oracle -C telnetd
If you are going to select few 10 process then, grep will not make any performance issue at all.
-Muthu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-27-2005 02:43 AM
тАО10-27-2005 02:43 AM
Re: Kill command
But let's suppose you want to get rid of all sh processes. If you do this:
ps -ef | grep sh
you will see some processes that you NEVER want to kill such as unhasdaemon. grep does not match a specific field, it matches anything on the line, so "grep sh" matches sh ksh csh bash unhasdaemon and even user or group names such sherry (who might be running vi on a critical file).
ALWAYS use "ps -C inserverD" because this does not use grep. Instead, -C looks in the process table and does an EXACT match. It will not find inserverD123 or XinserverD. Now the -C option (and -H and -o) are XPG$ options and must be enabled with the temporary variable UNIX95. Just put the temp assignment in front of ps:
UNIX95=1 ps -fC inserverD
and magically, only inserverD processes will be found. This also finds any possible way of starting the process, from /inserver54_pro/bin/inserverD to ./inserverD and so on. Note that -C is much faster than -e and grep.
Once you have the inserverD list, then you can kill the processes using kill -15 first, then kill -1 if any are left, and finally kill -9 if the first 2 do not work.
Bill Hassell, sysadmin