Linux每隔1秒kill掉cpu大于50%的进程
1.新建/test/killcpu.sh shell脚本 并授予权限0755
#!/bin/bash
ps axf -o "pid %cpu" | awk '{if($2>=50.0) print $1}' | while read procid
do
kill -9 $procid
done
2.安装crontab
yum -y install vixie-cron
3.查看定时任务 crontab -l
4.添加定时任务 crontab -e
分   时   日   月   周   命令
第1列表示分钟1~59 每分钟用*或者 */1表示
第2列表示小时1~23(0表示0点)
第3列表示日期1~31
第4列表示月份1~12
第5列标识号星期0~6(0表示星期天)
第6列要运行的命令
## For excuting killcpu.sh every 3 seconds##on 2017-03-09 每3秒执行脚本
*/1 * * * *  /test/killcpu.sh
*/1 * * * * sleep 3 &&  /test/killcpu.sh
*/1 * * * * sleep 6 &&  /test/killcpu.sh
*/1 * * * * sleep 9 &&  /test/killcpu.sh
*/1 * * * * sleep 12 &&  /test/killcpu.sh
*/1 * * * * sleep 15 &&  /test/killcpu.sh
*/1 * * * * sleep 18 &&  /test/killcpu.sh
*/1 * * * * sleep 21 &&  /test/killcpu.sh
*/1 * * * * sleep 24 &&  /test/killcpu.sh
*/1 * * * * sleep 27 &&  /test/killcpu.sh
*/1 * * * * sleep 30 &&  /test/killcpu.sh
*/1 * * * * sleep 33 &&  /test/killcpu.sh
*/1 * * * * sleep 36 &&  /test/killcpu.sh
*/1 * * * * sleep 39 &&  /test/killcpu.sh
*/1 * * * * sleep 42 &&  /test/killcpu.sh
*/1 * * * * sleep 45 &&  /test/killcpu.sh
*/1 * * * * sleep 48 &&  /test/killcpu.sh
*/1 * * * * sleep 51 &&  /test/killcpu.sh
*/1 * * * * sleep 54 &&  /test/killcpu.sh
*/1 * * * * sleep 57 &&  /test/killcpu.sh
#-----------------------------------------------------------------
## For excuting killcpu.sh every 1 seconds##on 2017-03-09 每1秒执行脚本
*/1 * * * *  /test/killcpu.sh
*/1 * * * * sleep 1 &&  /test/killcpu.sh
*/1 * * * * sleep 2 &&  /test/killcpu.sh
*/1 * * * * sleep 3 &&  /test/killcpu.sh
*/1 * * * * sleep 4 &&  /test/killcpu.sh
*/1 * * * * sleep 5 &&  /test/killcpu.sh
*/1 * * * * sleep 6 &&  /test/killcpu.sh
*/1 * * * * sleep 7 &&  /test/killcpu.sh
*/1 * * * * sleep 8 &&  /test/killcpu.sh
*/1 * * * * sleep 9 &&  /test/killcpu.sh
*/1 * * * * sleep 10 &&  /test/killcpu.sh
*/1 * * * * sleep 11 &&  /test/killcpu.sh
*/1 * * * * sleep 12 &&  /test/killcpu.sh
*/1 * * * * sleep 13 &&  /test/killcpu.sh
*/1 * * * * sleep 14 &&  /test/killcpu.sh
*/1 * * * * sleep 15 &&  /test/killcpu.sh
*/1 * * * * sleep 16 &&  /test/killcpu.sh
*/1 * * * * sleep 17 &&  /test/killcpu.sh
*/1 * * * * sleep 18 &&  /test/killcpu.sh
*/1 * * * * sleep 19 &&  /test/killcpu.sh
*/1 * * * * sleep 20 &&  /test/killcpu.sh
*/1 * * * * sleep 21 &&  /test/killcpu.sh
*/1 * * * * sleep 22 &&  /test/killcpu.sh
*/1 * * * * sleep 23 &&  /test/killcpu.sh
*/1 * * * * sleep 24 &&  /test/killcpu.sh
*/1 * * * * sleep 25 &&  /test/killcpu.sh
*/1 * * * * sleep 26 &&  /test/killcpu.sh
*/1 * * * * sleep 27 &&  /test/killcpu.sh
*/1 * * * * sleep 28 &&  /test/killcpu.sh
*/1 * * * * sleep 29 &&  /test/killcpu.sh
*/1 * * * * sleep 30 &&  /test/killcpu.sh
*/1 * * * * sleep 31 &&  /test/killcpu.sh
*/1 * * * * sleep 32 &&  /test/killcpu.sh
*/1 * * * * sleep 33 &&  /test/killcpu.sh
*/1 * * * * sleep 34 &&  /test/killcpu.sh
*/1 * * * * sleep 35 &&  /test/killcpu.sh
*/1 * * * * sleep 36 &&  /test/killcpu.sh
*/1 * * * * sleep 37 &&  /test/killcpu.sh
*/1 * * * * sleep 38 &&  /test/killcpu.sh
*/1 * * * * sleep 39 &&  /test/killcpu.sh
*/1 * * * * sleep 40 &&  /test/killcpu.sh
*/1 * * * * sleep 41 &&  /test/killcpu.sh
*/1 * * * * sleep 42 &&  /test/killcpu.sh
*/1 * * * * sleep 43 &&  /test/killcpu.sh
*/1 * * * * sleep 44 &&  /test/killcpu.sh
*/1 * * * * sleep 45 &&  /test/killcpu.sh
*/1 * * * * sleep 46 &&  /test/killcpu.sh
*/1 * * * * sleep 47 &&  /test/killcpu.sh
*/1 * * * * sleep 48 &&  /test/killcpu.sh
*/1 * * * * sleep 49 &&  /test/killcpu.sh
*/1 * * * * sleep 50 &&  /test/killcpu.sh
*/1 * * * * sleep 51 &&  /test/killcpu.sh
*/1 * * * * sleep 52 &&  /test/killcpu.sh
*/1 * * * * sleep 53 &&  /test/killcpu.sh
*/1 * * * * sleep 54 &&  /test/killcpu.sh
*/1 * * * * sleep 55 &&  /test/killcpu.sh
*/1 * * * * sleep 56 &&  /test/killcpu.sh
*/1 * * * * sleep 57 &&  /test/killcpu.sh
*/1 * * * * sleep 58 &&  /test/killcpu.sh
*/1 * * * * sleep 59 &&  /test/killcpu.sh
#-----------------------------------------------------------------
5.重启服务 service crond restart
6.添加开机启动 chkconfig --list crond
7.查看开机启动服务 chkconfig
Linux每隔1秒kill掉cpu大于50%的进程的更多相关文章
- 【每天一条Linux指令-Day1】kill掉多个mysql的进程
		
我被问到过一个shell的问题,问的是如何kill掉多个mysql的进程? 怎么把这个的pid传递下去 ps -ef|grep mysql | xargs kill -9 ps -ef|grep my ...
 - mysql中kill掉所有锁表的进程
		
--mysql中kill掉所有锁表的进程 --------------------------------2014/05/20 在数据库的管理中,我们经常会碰到锁表的问题,看一下进程列表. mysql ...
 - 找出 alter system kill session ‘sid,serial#’ kill 掉的数据库会话对应进程
		
当我们使用alter system kill session ‘sid,serial#’ 在数据库中kill掉某个会话的时候,如果你观察仔细会发现v$session.paddr发生了改变,从而是的不能 ...
 - 批量kill掉包含某个关键字的进程
		
需要把 linux 下符合某一项条件的所有进程 kill 掉,又不能用 killall 直接杀掉某一进程名称包含的所有运行中进程(我们可能只需要杀掉其中的某一类或运行指定参数命令的进程),这个时候我们 ...
 - linux 查看占用端口并kill掉
		
主要可以使用ps 命令 或 netstat 命令 weihong@data1:~/jd_parser/jd_parser$ ps aux | head USER PID %CPU %MEM VSZ ...
 - linux 因内存不足而 kill 掉 java 程序
		
grep "Out of memory" /var/log/messages Sep 17 16:13:34 xxxaaa kernel: Out of memory: Kill ...
 - linux, kill掉占用60%多cpu的进程,几秒后换个pid 和 command 又出现
		
linux, kill掉占用60%多cpu的进程,几秒后换个pid 和 command 又出现?快速清理木马流程.假设木马的名字是xysbqaxjqy,如果top看不到,可以在/etc/init.d目 ...
 - 编写shell脚本kill掉占用cpu超过90%以上的程序
		
由于集群用户经常会不懂如何提交作业,将作业直接运行到登录节点上,这样导致登录节点的cpu及内存占用很大,导致其他用户甚至无法登录.所以就想到了一种解决方法,写一个shell脚本,常驻登录节点,监控cp ...
 - 【shell脚本实例】一个恶作剧—— kill掉占用CPU较高的matlab进程
		
我们实验室有台服务器,博士们在服务器上跑MATLAB,基本都是4核都是超过95%的CPU占用,想了个恶作剧的shell 定时kill掉MATLAB程序,是不是很邪恶啊,哈哈~~~ 不过我只是干过一次 ...
 
随机推荐
- 到达型01背包---P1504 积木城堡
			
P1504 积木城堡 题解 到达型01背包 对于每一组城堡,它可以到达一些高度 但是我们要求的是所有背包可以到达的公共高度的最大值 f[ i ] 表示对于一组城堡,能否到达高度 j ,然后我们跑 n ...
 - Android下拉涮新第三方通用控件
			
Android下拉涮新第三方通用控件https://github.com/chrisbanes/Android-PullToRefresh Pull To Refresh Views for Andr ...
 - Quartz.Net 学习随手记之03 配置文件
			
第一种方式:直接写入代码中 NameValueCollection properties = new NameValueCollection(); properties["quartz.sc ...
 - Realsense D430 save
			
rs-save-to-disk.cpp // License: Apache 2.0. See LICENSE file in root directory. // Copyright(c) 2015 ...
 - 算法习题---3.08循环小数(UVa202)
			
一:题目 输入整数a和b(<=a<=,<=b<=),输出a/b的循环小数表示以及循环节长度. 例如,a=,b=,小数表示为0.(),循环字节长度为21 当循环节长度超过50时, ...
 - nginx在windows系统中如何启动、重启、停止
			
nginx在windows系统中如何启动.重启.停止 查看nginx的版本号:nginx -v 启动nginx:start nginx 快速停止或关闭nginx:nginx -s stop 正常停 ...
 - 创建IDOC
			
第一步:WE31 创建IDOC所包含的字段. 第二步:WE30 创建IDOC 把Segment分配给IDOC 第三步:WE81 创建信息类型 第四步:WE82 把IDOC类型与信息类型对应. 第五步: ...
 - 【Leetcode_easy】824. Goat Latin
			
problem 824. Goat Latin solution class Solution { public: string toGoatLatin(string S) { unordered_s ...
 - MVC模式实现注册登录
			
很多人对MVC模式搞不懂,刚开始是我也犯迷糊,知道看到一个前辈写的代码,我顿时有的恍然大悟,拿来分享给各位 MVC: 就是M:模型.V:视图(前台界面)C:后台处理的servlet 话不多说.上代码 ...
 - 【计算机视觉】OPENCV对于有alpha通道的透明背景图片的读取和图片叠加
			
这个是我自己做的粗略的螺旋丸的图,导出为png并带有alpha通道. 最后和一只狗合成成这个样子. 效果还是可以的. 为了实现这个效果,首先我们要明白具有透明通道的图片的OpenCV的读取方式.在Op ...