首页 > Web开发 > 详细

php后台服务防止交叉执行

时间:2016-04-12 16:07:31      阅读:258      评论:0      收藏:0      [点我收藏+]

sudo mkdir /alidata/www/office/orderlog/
sudo chown www:www /alidata/www/office/orderlog/ -R
sudo chmod 777 /alidata/www/office/orderlog/ -R
sudo vim /alidata/www/office/allocate_order.sh

#!/bin/bash
count=`ps aux|grep ‘hh/auto-process-order‘|grep -v ‘grep‘|wc -l`
if [ 0 == ${count} ];then
        orderlog_dir=/alidata/www/office/orderlog/`date +%y%m%d`/
        orderlog_file=${orderlog_dir}`date +%H`
        if [ ! -d ${orderlog_dir} ]; then
                mkdir -p ${orderlog_dir}
        fi
        if [ ! -f ${orderlog_file} ]; then
                touch ${orderlog_file}
        fi
        /alidata/server/php/bin/php /alidata/www/office/yii hh/auto-process-order >> ${orderlog_file}
fi

sudo chown www:www /alidata/www/office/allocate_order.sh


crontab -e
*/1 * * * * /alidata/www/office/allocate_order.sh

php后台服务防止交叉执行

原文:http://hehe1987.blog.51cto.com/2094458/1762967

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!