需求:IEE数据库临时需要添加一个监控,将command为sleep,time>1800,info为null的进程自动杀掉。
1.杀进程脚本ieekill.sh内容如下
#!/bin/bash#Usage: IEE kill process whose time more than 1800s.. #ex: sh ieekill.sh >> /tmp/ieekill.log #Author: Alfred Zhao#Version: 1.0.0export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bindateif [ -f /tmp/kill_iee_id.txt ]; then echo "rm -rf /tmp/kill_iee_id.txt" rm -rf /tmp/kill_iee_id.txtelse echo "go on"fimysql-ib <1800 INTO OUTFILE '/tmp/kill_iee_id.txt';source /tmp/kill_iee_id.txtEOF
2.定时调用脚本定时配置
crontab -e 添加下面的配置,每小时执行1次杀进程脚本。
0 * * * * sh /tmp/ieekill.sh >> /tmp/ieekill.log