国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統(tǒng) > Linux > 正文

自動殺掉占用較多CPU資源的Shell腳本

2019-10-26 18:40:54
字體:
供稿:網(wǎng)友

代碼如下:
#!/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

發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 乐平市| 宜章县| 越西县| 综艺| 乌什县| 江北区| 重庆市| 澄迈县| 江城| 霍州市| 西乡县| 拜泉县| 郎溪县| 东山县| 保山市| 苍梧县| 湖南省| 瓮安县| 蓝山县| 安西县| 平湖市| 吴忠市| 平阳县| 肇庆市| 北辰区| 佛冈县| 五峰| 沙田区| 买车| 吐鲁番市| 营口市| 明溪县| 抚远县| 泰和县| 报价| 龙州县| 福建省| 泸州市| 巴彦淖尔市| 白朗县| 开原市|