shell 记录

数组,多线程  

urlcmd='/root/cmd/'
for i in {0..47}
do
        arr=(`${urlcmd}cmd $i  | grep 'Number'|awk -F '[' '{print $2}'|awk -F ']' '{print $1}'`)
        if [ -z ${#arr[*]} ];then
                :
        else
                for j in "${!arr[@]}"
                do
                {
                        on_chain=`${urlcmd} ${arr[$j]} --on-`
                        ticket=`echo $on_chain | grep -E 'Ticket:'|awk '{print $10}'`
                        commR=`echo  $on_chain | grep -E 'CIDcommR:'|awk '{print $8}'`
                        echo "--id=${arr[$j]} --ticket=${ticket} --commR=${commR}" >> t.file
                } &
                done
        fi
done

 文件刷新时间计算,日志文件截取

#!/bin/bash
str=`tail -n 1 recove.log | grep 'removin'`
str1=`tail -n 1 recove.log | grep 'Fetchin'`
if [ -z "$str" -o -z "$str1" ];then
        file='recove.log'
        #获取文件修改时间
        last_time=$(stat -c %Y $file)
        #获取当前时间
        ndate=`date +%s`
        #文件修改时间
        timediff=$[$ndate -$last_time]
        if [ $timediff -gt 300 ];then
                #获取id
                [ ! -z "$str" ] && id=`echo $str |grep -oE "sector [0-9]+" |awk '{print $2}'`
                [ ! -z "$str1" ] && id=`echo $str1 |grep -oE "sector [0-9]+" |awk '{print $2}'`
                if [ -f s-t0470608-$id -a -f $id ];then
                        filesize=`ls -l s-t0470608-$id | awk '{print $5}'`
                        if [ $filesize -eq 68719476736 ];then
                                kill -9 $(ps -e|grep ' lotus-recover$'|awk '{printf $1}')
                        fi
                else
                        echo "缺少/文件"
                fi

        fi
fi

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值