getConnection(); echo "Iniciando limpeza de logs antigos (> $daysToKeep dias)...\n"; // Calcular data de corte $cutoffDate = date('Y-m-d H:i:s', strtotime("-$daysToKeep days")); // Executar limpeza $stmt = $conn->prepare("DELETE FROM api_logs WHERE created_at < :cutoff"); $stmt->execute(['cutoff' => $cutoffDate]); $deletedCount = $stmt->rowCount(); echo "Limpeza concluída. $deletedCount registros removidos.\n"; } catch (Exception $e) { echo "Erro: " . $e->getMessage() . "\n"; exit(1); }