Chinaunix首页 | 论坛 | 博客
  • 博客访问: 156390
  • 博文数量: 47
  • 博客积分: 2318
  • 博客等级: 大尉
  • 技术积分: 471
  • 用 户 组: 普通用户
  • 注册时间: 2009-11-25 12:09
文章分类

全部博文(47)

文章存档

2012年(17)

2011年(28)

2010年(2)

分类: LINUX

2011-10-28 10:39:41

#################################################################
#
#互斥运行
#
#################################################################
mutex_Run()
{
if [ -e /tmp/spg_export_log_tmp.sh ];then
        rm -f /tmp/spg_export_log_tmp.sh >> ${LOG_FILE}  2>&1;
fi
#看到这个变量中的进程存在就停一会再运行
mutex_FileName="spg_autoexport_log.sh"

while :
do
  process=`ps -ef |grep "$mutex_FileName" |grep -v grep`
  if [ "${process}" == "" ];then
      break;
      echo "`date +%Y-%m-%d\ %H:%M:%S` ok now start runing the script to export log " >> ${LOG_FILE}  2>&1;
  else
      echo "$process" >> ${LOG_FILE}  2>&1;
      echo "`date +%Y-%m-%d\ %H:%M:%S` spg_export_log.sh is runing other script ,and sleep 3 second. " >> ${LOG_FILE}  2>&1;
          echo '
          #!/bin/sh
          mutex_FileName_tmp="spg_autoexport_log.sh"
          while :
          do
            process_tmp=`ps -ef |grep "$mutex_FileName" |grep -v grep`;
                if [ "${process_tmp}" == "" ];then
                   sh /opt/SPG2800/util/log_export/spg_export_log.sh;
                   echo "`date +%Y-%m-%d\ %H:%M:%S` spg_export_log.sh start rung...... " >> ${LOG_FILE}  2>&1;
                   exit 0;
                else
                   echo "`date +%Y-%m-%d\ %H:%M:%S`the process_tmp=$process_tmp"........ >> ${LOG_FILE}  2>&1;
                   echo "`date +%Y-%m-%d\ %H:%M:%S` spg_export_log.sh is runing other script ,and sleep 3 second. " >> ${LOG_FILE}  2>&1;
                   sleep 3;
                fi
                    
          ' >/tmp/spg_export_log_tmp.sh
          if [ -e /tmp/spg_export_log_tmp.sh ];then
            sh /tmp/spg_export_log_tmp.sh >> ${LOG_FILE}  2>&1;
          fi
               
          exit 1;
  fi
done
}
阅读(2310) | 评论(0) | 转发(0) |
0

上一篇:国外VPS销售中心

下一篇:持续集成戒律

给主人留下些什么吧!~~