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程序,是不是很邪恶啊,哈哈~~~ 不过我只是干过一次 ...
随机推荐
- JAVA RDD 介绍
RDD 介绍 RDD,全称Resilient Distributed Datasets(弹性分布式数据集),是Spark最为核心的概念,是Spark对数据的抽象. RDD是分布式的元素集合,每个RDD ...
- error: cannot connect to daemon解决办法
本文链接:https://blog.csdn.net/ipinki1218/article/details/80704806运行adb shell时出现error: cannot connect to ...
- @Deprecated注解
它的作用是对不应该再使用的方法添加注解,当编程人员使用这些方法时,将会在编译时显示提示信息,它与javadoc里的@deprecated标记有相同的功能,准确的说,它还不如javadoc @depre ...
- jsp中cookie的一个报错
写项目时在一个jsp页面中使用了cookie,用逗号分隔的数据,服务器老报错,搞了一个小时,终于清楚了,jsp的cookie中不能使用逗号. cookie规则:这个规则用于jsp.asp中(下面这两句 ...
- ABAP ole操作
1.ole 如何保存和退出call method of sheetname 'saves' exporting #1 = filepath #2 = 1. call method of applica ...
- Linux - Linux命令行常用快捷键
Common Shortcut Key 用途 快捷键 说明 光标移动 Ctrl + a 把光标移到行首 Ctrl + e 把光标移到行尾 Ctrl + x 在 EOL 和当前位置移动光标 输入编辑 C ...
- Tools - Nmap
Nmap Homepage Nmap参考指南(Man Page) Nmap中文网 wiki - Nmap 常用示例 1) Ping扫描,打印出对扫描做出响应的主机 nmap -sP 192.168.1 ...
- page工具类
工具类 /** * @Title: PageUtil.java * @Package * @Description: TODO(用一句话描述该文件做什么) * @author licy * @date ...
- win10 安装MySQL过程和遇到的坑
环境:win10系统,MySQL5.7.18 “mysql-5.7.18-winx64.msi” 首先是要运行mysql-5.7.18-winx64.msi,选择安装在C盘(可自定义安装) 第一步 打 ...
- 【计算机视觉】Selective Search for Object Recognition论文阅读3
Selective Search for Object Recoginition surgewong@gmail.com http://blog.csdn.net/surgewong 在前 ...