几种监控用定时任务

[url]http://sanyuesan3.taobao.com/[/url]

网络连接数监控:
echo "`date +\"%H:%M:%S\"`" >> /home/count/netstatmonitor/netmonitor.`date +%Y%m%d`
netstat -n |grep 7001| awk '/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}' >> /home/count/netstatmonitor/netmonitor.`date +%Y%m%d`


监控进程是否存在并重启:
#!/bin/bash
echo > /home/count/start/testOK.jsp
wget -q http://localhost:7001/templet/testOK.jsp -O /home/count/start/testOK.jsp &
#wget -q --no-check-certificate https://localhost:8443/templet/testOK.jsp -O /home/count/start/testOK.jsp &
sleep 5
cd /home/count/start
size=$(ls -l | grep testOK.jsp | awk '{printf $5}')
zero=0
rightline=7
right=7

if [ $size -eq $right ]; then
echo "`date +\"%H:%M:%S\"` sss is ok" >> /home/count/start/`date +%Y%m%d`.data
rm -f /home/count/start/line
else
echo "`date +\"%H:%M:%S\"` sss is not ok" >> /home/count/start/`date +%Y%m%d`.data
process=$(ps -ef | grep tomcat | grep -c sss)
if [ $process -gt $zero ]; then
echo 1 >> /home/count/start/line
linenum=$(wc -l /home/count/start/line | cut -c 1)
if [ $linenum -gt $rightline ]; then
rm -f /home/mecp/count/start/line
num=$(ps -ef | grep tomcat | grep sss | head -n 1 | awk '{printf $2}')
kill -9 $num
sleep 10
num=$(ps -ef | grep tomcat | grep -c sss)
if [ $num -gt $zero ]; then
num=$(ps -ef | grep tomcat | grep sss | head -n 1 | awk '{printf $2}')
kill -9 $num
sleep 10
fi
. /home/sss/setenv.sh
/home/tomcat-6.0.32/bin/startup.sh
fi
else
rm -f /home/count/start/line
. /home/setenv.sh
/home/tomcat-6.0.32/bin/startup.sh
fi
fi



做时间同步:
# crontab -l
*/30 * * * *  /usr/sbin/ntpdate 40.40.40.100



执行sql操作
#!/bin/bash
v_date=$(date +%Y%m%d);
/oracle/product/10.2.0/bin/sqlplus -s 'name/passwaord@sid'<<EOF
set pages 0
set feed off
set heading off;
set feedback off;
set verify off;
set trimout on;
set trimspool on;
set trims on;
set linesize 4000;
set pagesize 4000;
spool /home/resourcesub_points_rec_$v_date.csv
SELECT '1'||','||trim(DONEDATE)||',' FROM ponitsinfo where substr(donedate,0,8) =(select to_char( dt ,'YYYYMMDD') dt from (select sysdate-1 dt from dual));
spool off
EOF
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值