gnuteca->files.''; } //procura no module if ( !$tmpPath ) { $confPath = $conf->home->modules . '/gnuteca3/etc/module.conf'; $confContent = file_get_contents($confPath); if ( $confContent ) { $conf = new SimpleXMLElement( $confContent ); $tmpPath = $conf->gnuteca->files.''; } } } if ( !$tmpPath ) { $tmpPath = $mioloPath . "/modules/{$module}/html/files"; } $gCronPath = $tmpPath . '/gcron.log'; $busFile = $MIOLO->getBusiness($module, 'BusUpdateSearch'); define(SLEEP_TIME, 60); //define ciclo de execução em segundos $executeDate = file_get_contents($gCronPath); //obtém a data/hora em que a gcron foi rodada pela última vez if ( strlen($executeDate) > 0 ) { $horaAnterior = substr($executeDate, 11,2); //obtém a hora de execução da GCron $minutoAnterior = ( $horaAnterior * 60 ) + substr($executeDate, 14,2); } else { $horaAnterior = ''; $minutoAnterior = ''; } //caso a gcron esteja rodando para processo if ( file_exists( $tmpPath . 'gcronrun' ) ) { $minutoAtual = date('H') * 60 + ( date('i') ); $diff = $minutoAnterior - $minutoAtual; //caso já tenha passado 10 minutos permite continuar if ( $diff > 10 ) { unlink( $tmpPath . 'gcronrun' ); } else { return true; } } file_put_contents( $tmpPath . 'gcronrun', 'gcronrun'); //registra que está rodando while(true) { file_put_contents($gCronPath, date('d/m/Y H:i:s')); //grava o log de execução $hour = date('H'); if ( $horaAnterior != $hour ) { exec("php $mioloPath/modules/{$module}/misc/scripts/runScheduleTasks.php true"); //thread que executa as tarefas $horaAnterior = $hour; } updateTable(); //executa a atualização da tabela de pesquisa //executa a GCron somente uma vez if ( $pSemWhile ) { break; } sleep(SLEEP_TIME); //aguarda o tempo estimado em SLEEP_TIME segundos } unlink( $tmpPath . 'gcronrun' ); ?>