Análise Cron Job WHMCS

4

Para que o WHMCS possa se tornar um sistema 100% automatizado é imprescindível que a cron job funcione corretamente. Se por algum motivo (falha no servidor ou erro na configuração) a cron não “rodar” diversas funções como criação/envio de faturas, suspensão/exclusão de contas, estatísticas do servidor, multas/juros e etc… não funcionaram e o sistema ficará comprometido.

O objetivo do post de hoje é realizar um checklist para garantir o funcionamento da cron job e que seu WHMCS funcione corretamente!

Configuração

A configuração da cron job não tem mistérios, a WHMCS.com fornece as instruções para cPanel, Direct Admin, DotNetPanel, Windows Server, Plesk, Helm e InterWorx confira aqui.

Se por algum motivo após cadastrar a tarefa e não funcionar solicite ao suporte do servidor/datacenter uma verificação nas permissões da cron (em 90% dos casos esse é o problema mais comum).

Análises

Se você configurou corretamente a cron e deseja verificar seu funcionamento passo-a-passo é simples, visite o menu Utilitários >> Log >> Log de Atividades do Sistema. Confira um exemplo:

Cron Job: Completed
Cron Job: Done
Cron Job: Starting Performing Client Status Sync
Cron Job: Done
Cron Job: Starting Updating Disk & Bandwidth Usage Stats
Cron Job: Starting Processing Email Marketer Rules
Cron Job: Processed X Pending Affiliate Payments
Cron Job: Starting Processing Delayed Affiliate Commissions
Cron Job: Starting Auto Closing Inactive Tickets
Cron Job: Processed X Terminations
Cron Job: Starting Performing Automated Fixed Term Service Terminations
Cron Job: Processed X Suspensions
Cron Job: Starting Processing Overdue Suspensions
Cron Job: Processed X Cancellations
Cron Job: Starting Processing Cancellation Requests
Cron Job: Sent X Notices
Cron Job: Starting Processing Domain Renewal Notices
Cron Job: Sent X Reminders
Cron Job: Sent X Unpaid Invoice Payment Reminders
Cron Job: Starting Processing Invoice Reminder Notices
Cron Job: Starting Processing Credit Card Charges
Cron Job: Late Invoice Fees added to X Invoices
Cron Job: Starting Applying Late Fees
Cron Job: X Invoices Created
Cron Job: Starting Generating Invoices
Cron Job: Done
Cron Job: Starting Updating Currency Exchange Rates
Cron Job: Running Pre-Cron Hooks
Cron Job: Starting (1)

A linha 29 Starting informa o inicio do processo de automatização e a linha 1 Completed o fim, as demais linhas que aparecerem são os detalhes de cada processo passo-a-passo.

Debug

Se por um acaso as linhas Starting e Completed não constarem no log indica alguma falha ( módulo, hook, addon e etc… ) uma forma de tentar achar o “culpado” é ativando o debug do WHMCS. Abra o arquivo configuration.php que fica localizado na pasta raiz da instalação e inclua a linha abaixo no final.

$display_errors="on";

Em seguida acesse diretamente no navegador https://seuwhmcs.com/seuadmin/cron.php e veja se surge algum erro.

Debug Avançado

Caso o primeiro debug não tenha funcionado existe uma alternativa muito melhor mas exige acesso via SSH. Se você não possuir acesso SSH por utilizar um ambiente compartilhado isso é normal, solicite ao suporte que execute a linha abaixo e te envie o resultado.

php -q /home/user/www/pasta/admin/cron.php debug

O debug avançado além de informar possíveis erros irá retornar a memória utilizada e o tempo para cada tarefa.

Starting (Time: 0.19 Memory: 15.63)
Running Pre-Cron Hooks (Time: 0.03 Memory: 15.63)
Starting Updating Currency Exchange Rates (Time: 0 Memory: 15.63)
 - Done (Time: 0.63 Memory: 15.63)
Starting Generating Invoices (Time: 0 Memory: 15.63)
 - 0 Invoices Created (Time: 0.03 Memory: 15.78)
Starting Applying Late Fees (Time: 0 Memory: 15.78)
 - Late Invoice Fees added to 0 Invoices (Time: 0 Memory: 15.78)
Starting Processing Credit Card Charges (Time: 0 Memory: 15.78)
Starting Processing Invoice Reminder Notices (Time: 0.01 Memory: 15.78)
 - Sent 0 Unpaid Invoice Payment Reminders (Time: 0 Memory: 15.78)
 - Sent 0 Reminders (Time: 0 Memory: 15.78)
Starting Processing Domain Renewal Notices (Time: 0 Memory: 15.78)
 - Sent 0 Notices (Time: 0 Memory: 15.78)
Starting Processing Cancellation Requests (Time: 0 Memory: 15.78)
 - Processed 0 Cancellations (Time: 0.01 Memory: 15.78)
Starting Processing Overdue Suspensions (Time: 0 Memory: 15.78)
 - Processed 0 Suspensions (Time: 0.01 Memory: 16.21)
Starting Performing Automated Fixed Term Service Terminations (Time: 0 Memory: 16.21)
 - Processed 0 Terminations (Time: 0.01 Memory: 16.21)
Starting Auto Closing Inactive Tickets (Time: 0 Memory: 16.21)
Starting Processing Delayed Affiliate Commissions (Time: 0 Memory: 16.21)
 - Processed 0 Pending Affiliate Payments (Time: 0.01 Memory: 16.21)
Starting Processing Email Marketer Rules (Time: 0 Memory: 16.21)
Starting Updating Disk & Bandwidth Usage Stats (Time: 0.01 Memory: 16.21)
 - Done (Time: -0.99 Memory: 16.47)
Starting Performing Client Status Sync (Time: 0 Memory: 16.47)
 - Done (Time: 0 Memory: 16.47)
Completed (Time: 0 Memory: 16.47)
Cron Job Hooks Run... (Time: 0.11 Memory: 17.26)
Starting Database Backup (Time: 0.01 Memory: 17.26)
Backup Complete... (Time: 0 Memory: 17.26)
Running After Cron Hooks (Time: 0 Memory: 17.26)
Goodbye (Time: 0 Memory: 17.26)

Espero que as dicas acima possam te ajudar caso você tenha problemas na automatização do seu WHMCS.

Neste link você poderá encontrar outros artigos sobre o tema Cron Job.

Gostou? Comente!

4 COMENTÁRIOS

DEIXE UMA RESPOSTA

Please enter your comment!
Please enter your name here