#!/usr/bin/php -q = (now()::date -3) and a.chm_data_bilhete < (now()::date) and coalesce(a.chm_controle, 9) = 9 and d.clas_descricao = 'VENDA' and c.prt_proto_parceiro <> '' "; $result = pg_query($query); while ($dados = pg_fetch_array($result, null, PGSQL_ASSOC)) { $id = $dados["id_unk"]; $origem = $dados["origem"]; $destino = $dados["destino"]; $controle = 9; if (file_exists($origem) && rename($origem, $destino)) { $controle = 1; } pg_query("update vds_chamadas set chm_controle = '{$controle}' where id_unk = '{$id}'"); usleep(300); } exec("chown -R algar:algar /hdaux");