The practical killing process of VMware using in Linux environment Tool__linux

Source: Internet
Author: User
In an integrated development environment, because of the high cost of hardware, several developers are often required to share a single hardware device.

A typical application is: two or three people share a device, Linux Server, and then use VMware to install their own debugging run environment, we share a user name (usually not root) landing. Due to the bottleneck of hardware performance bottlenecks, only one virtual machine can be run at the same time (theoretically, it is possible to run multiple virtual machines simultaneously, but the speed is slow, the performance cannot keep up with the actual application). When the current user logs on to use the hardware device, need to kill other colleagues left over the process (theoretically should be the initiator of the process to clean up, but may often be forgotten, similar to the toilet forgot to flush), when the current user needs to use the command "Ps-ef|grep VMware" to view the legacy process number, Then use the command "Kill-9 ProcessID" to kill. Often do so, very cumbersome trouble, so I wrote a tool, tested a bit, very good, and specifically share.


Source code is as follows

#!/bin/ksh

if [[$ = =]]
then
	print "KO username, please input username!"
	Exit 1
fi

username=$1
print "\nbefore kill:\n"
ps-ef|grep vmware
print \nkilling ... "
Echo > Tmp.txt
ps-ef|grep "^${username}.*vmware" |grep-v Grep|awk ' {print $} ' >>. tmp.txt while

read Li Ne
do
	if [[${line}!=]]; Then
		kill-9 ${line}
	fi do
<.tmp.txt
rm. Tmp.txt Sleep
2
print "\nafter kill:\n"
ps-ef|grep VMware
exit 0

Run results




Extended

If you want to kill another process associated with a user (with a keyword), just replace the VMware keyword in the script, and the students who need it can change their own.


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.