shell 脚本执行任务

#!/bin/bash
source /etc/profile

tenant_list=`cat /home/web/hy_bash/tenant_app_id`
lock_file="/home/web/hy_bash/mutex"
CAT_FILE=`cat /home/web/hy_bash/mutex`
log_file="/home/web/hy_bash/log"
TIME=`/usr/bin/date`

# 避免死锁
mutexmtime=`/usr/bin/stat -c %Y /home/web/hy_bash/mutex`
now_time=`/usr/bin/date +%s`
if [ $[ $now_time - $mutexmtime ] -gt 120 ]
then
   echo 0 > $lock_file
   exit
fi

echo "start_time:${TIME}" >> $log_file

if [ $CAT_FILE == 1 ]
then
    #echo 锁定状态
    echo "lock in use:${TIME}" >> $log_file
    exit
else 
   for tenant_id in $tenant_list
     do
       echo 1 > $lock_file
       #echo $tenant_id: $TIME  >> /home/web/hy_bash/aalog
       cd /home/web/hy_test/public
       /usr/bin/php index.php pushWaybill  $tenant_id
     done
    
    end_time=`/usr/bin/date`
    echo "end_time:${end_time}" >> $log_file

   echo 0 > $lock_file
fi
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值