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
| Task | When | Configurable Setting |
|---|---|---|
| Generate invoices | X days before due date | Settings → Billing → Invoice Days Before |
| Send invoice email | On invoice creation | Email Templates → Invoice Created |
| Suspend services | Y days after due date unpaid | Settings → Automation → Suspend After (days) |
| Terminate services | Z days after suspension | Settings → Automation → Terminate After (days) |
| Domain expiry reminders | 30, 14, 7, 1 days before expiry | Email Templates → Domain Expiry Reminder |
| Auto-renew domains | 3 days before expiry | Per-domain auto_renew flag |
| Escalate tickets | After X hours with no reply | Settings → Support → Escalate After (hours) |
| Affiliate payouts | 1st of each month | Manual approval required |
| Prune rate limit table | Every run | Automatic |
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');")