Utility Script 5-batch kill process with process name

Source: Internet
Author: User

Share a script that kills a process through the process name, no need to find the process number one by one kills, greatly improves the productivity
How to use: Kproc Program 1 Program 2 ...

Script File Kproc

#!/bin/Shprgn= ' basename $0' Tmpf="/var/tmp/$PRGN. $$"quit () {RM-F $TMPF Exit $1}#===============# # MAIN Entrance # #===============#if[$#-lt1 ]; Then Echo"Usage: $PRGN {process_name}"quit1Fiuid= ' ID-u 'if[$uid-eq0 ]; Then Echo"Superuser cannot use this program!"quit1fi while[$#-ge1]; DoPS-f-u $uid | grep $1| Egrep-v"grep|kproc|vi|pts">$TMPF CNT= ' Cat $TMPF | WC-l ' while[$cnt-GT0]; Do Line= ' Sed-n"${cnt}p"$TMPF ' PID= ' echo $line | Cut-d" "-F2 ' Kill- -$pid Echo Stop $1---$pid CNT= ' Expr $cnt-1' Done Shiftdonequit0

Utility Script 5-batch kill process with process name

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.