利用指令碼kill掉進程, 文法:運行指令碼+進程名,指令碼kill

來源:互聯網
上載者:User

利用指令碼kill掉進程, 文法:運行指令碼+進程名,指令碼kill

下面附上指令碼, 許可權需要附X執行

#!/bin/sh#pid kill thread for chenglee#if fileformat=dos, update fileformat=unix#code:set fileformat=unix#check:set ff ?if [ $# -lt 1 ]then  echo "not procedure_name"  exit 1fi PROCESS=`ps -ef|grep $1|grep -v grep|grep -v PPID|awk '{ print $2}'`for i in $PROCESSdo  echo "Kill the $1 process [ $i ]"  kill -9 $idone

然後看一下編碼是否是unix, 之前我寫的時候在kalilinux裡面顯示的是dos, 如果是dos的話修改一下, sh指令碼需要unix

set fileformat=unix 

文法:

 ./shell.sh nginx

(kill掉nginx所有的進程, 解除繁瑣的pid操作)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.