佳木斯湛栽影视文化发展公司

主頁 > 知識(shí)庫 > 自動(dòng)殺掉占用較多CPU資源的Shell腳本

自動(dòng)殺掉占用較多CPU資源的Shell腳本

熱門標(biāo)簽:百度競價(jià)排名 網(wǎng)站排名優(yōu)化 地方門戶網(wǎng)站 服務(wù)外包 鐵路電話系統(tǒng) AI電銷 呼叫中心市場需求 Linux服務(wù)器

復(fù)制代碼 代碼如下:

#!/bin/bash

# March-13-2006
# CPUuse trigger script by Noel
#
# bash code to watch a running program's CPU usage.
# if it's above a set value, it will auto send an email.
# You will need to set a Cron job to run this script every xx minutes
#
# Set some needed things:
#
processToWatch="convert" # in my case I need to watch convert
emailAddress="root@host" # this is my main emailaddress
triggerValue=90 # if the CPU use is above 90% send an email. DO NOT USE a DOT or COMMA!
tempFileName=tmp-cpu # some name of the temp file for the ps, grep data

ps auxww | grep "$processToWatch" | grep -v grep > /tmp/$tempFileName
export LINE
(
read LINE
while [ -n "$LINE" ]
do
set $LINE
read LINE
if [ $(echo "$3" | sed -e 's/\.[0-9]*//g') -gt $triggerValue ]; then
mail -s "CPU message alert for: $processToWatch" $emailAddress -END
This is to inform you that the following process: $processToWatch with PID (Process ID) $2 is now using more than your preset $triggerValue value.

Process: $processToWatch is using: $3 of CPU power!
The command used is: $11
END
fi
done
) /tmp/$tempFileName

您可能感興趣的文章:
  • 一個(gè)用了統(tǒng)計(jì)CPU 內(nèi)存 硬盤 使用率的shell腳本
  • 統(tǒng)計(jì) cpu 內(nèi)存 使用率的shell腳本代碼
  • 消耗CPU資源的shell腳本
  • 使用shell腳本采集系統(tǒng)cpu、內(nèi)存、磁盤、網(wǎng)絡(luò)等信息
  • Linux中使用Shell腳本查看Java線程的CPU使用情況
  • Shell腳本實(shí)現(xiàn)把進(jìn)程負(fù)載均衡到多核CPU中
  • shell腳本監(jiān)控系統(tǒng)負(fù)載、CPU和內(nèi)存使用情況
  • Linux shell腳本實(shí)現(xiàn)CPU預(yù)警

標(biāo)簽:崇左 黃山 湖南 銅川 蘭州 湘潭 仙桃 衡水

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《自動(dòng)殺掉占用較多CPU資源的Shell腳本》,本文關(guān)鍵詞  ;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 收縮
    • 微信客服
    • 微信二維碼
    • 電話咨詢

    • 400-1100-266
    民乐县| 乌审旗| 思南县| 兴义市| 玛沁县| 牡丹江市| 吉林省| 宜黄县| 南通市| 泰顺县| 射洪县| 应用必备| 牡丹江市| 苍山县| 大足县| 乌兰察布市| 天祝| 繁昌县| 哈尔滨市| 衢州市| 三亚市| 玉林市| 台中市| 绩溪县| 阿克陶县| 青铜峡市| 清水县| 利辛县| 泸州市| 宜川县| 昆明市| 利津县| 房山区| 永新县| 伊春市| 阿克陶县| 古浪县| 湖南省| 南华县| 大英县| 穆棱市|