Cron Jobs

CloudBill Pro's automation engine runs via a cron job. It handles invoice generation, service suspension, domain renewals, and more.

Setup

Add one of the following to your server's crontab (crontab -e):

Option A — PHP CLI (recommended)

* * * * * /usr/bin/php /home/user/public_html/crons/cron.php >> /home/user/logs/cbpro-cron.log 2>&1

Option B — Web URL

First, set a cron secret in Admin → Settings → System → Cron Secret Key. Then:

* * * * * curl -s "https://billing.yourdomain.com/cron?secret=YOUR_SECRET" >> /home/user/logs/cbpro-cron.log
The cron runs every minute but each task only executes when its conditions are met — there is no duplicate processing.

What the Cron Does

TaskWhenConfigurable Setting
Generate invoicesX days before due dateSettings → Billing → Invoice Days Before
Send invoice emailOn invoice creationEmail Templates → Invoice Created
Suspend servicesY days after due date unpaidSettings → Automation → Suspend After (days)
Terminate servicesZ days after suspensionSettings → Automation → Terminate After (days)
Domain expiry reminders30, 14, 7, 1 days before expiryEmail Templates → Domain Expiry Reminder
Auto-renew domains3 days before expiryPer-domain auto_renew flag
Escalate ticketsAfter X hours with no replySettings → Support → Escalate After (hours)
Affiliate payouts1st of each monthManual approval required
Prune rate limit tableEvery runAutomatic

Checking Cron Logs

Sample log output:

[2024-01-15 02:00:01] === CloudBill Pro Cron Started ===
[2024-01-15 02:00:01] Checking services due on or before 2024-01-22...
[2024-01-15 02:00:01] Generated invoice #INV-A3F7B2C1 for service #12 (client #5)
[2024-01-15 02:00:01] Suspending services unpaid for more than 3 days...
[2024-01-15 02:00:01] Checking domain expiry reminders...
[2024-01-15 02:00:01] Domain example.com expiring in 7 days — reminding [email protected]
[2024-01-15 02:00:01] === Cron Completed ===

cPanel Setup

In cPanel → Cron Jobs → Add a New Cron Job:

  • Minute: *
  • Hour: *
  • Day: *
  • Month: *
  • Weekday: *
  • Command: php /home/username/public_html/crons/cron.php

Troubleshooting

If the cron doesn't run:

  • Verify the PHP binary path: which php
  • Test manually: php /path/to/crons/cron.php
  • Check for PHP errors in the log file
  • Ensure the database connection works from CLI (test with php -r "new PDO('mysql:host=localhost;dbname=test', 'user', 'pass');")