WHMCS Custom Cron Settings Guide
Setting up custom cron jobs in WHMCS is essential for automating various tasks like billing, invoice generation, domain synchronization, and more. This guide explains the purpose, configuration, and customization of cron settings in WHMCS, allowing you to optimize system performance and ensure seamless automation.
What is WHMCS System Cron?
The System Cron is a core feature in WHMCS that automates recurring tasks such as billing, notifications, and maintenance. Properly configuring it ensures smooth operation and consistent task execution.
Setting Up System Cron
-
Locating the Cron Command
To find the correct cron command:- Go to Configuration > System Settings > Automation Settings in your WHMCS admin panel.
- Copy the cron command provided, which looks like this:
*/5 * * * * php -q /home/username/crons/cron.php
- Replace
/home/username/crons/cron.php
with your actual cron.php path.
-
Configuring the Cron Job
Use your hosting control panel (like cPanel or Plesk) or the command line to add the cron job. For example:- For a 5-minute interval:
*/5 * * * * php -q /path/to/cron.php
- For a 5-minute interval:
-
Adjusting Execution Time
Set the time for daily automated tasks via Configuration > System Settings > Automation Settings > Time of Day. Ensure the cron runs during the set hour.
Common Cron Tasks
-
System Cron
- Runs core automation tasks like invoice generation, billing, and service management.
- Recommended interval: Every 5 minutes. Minimum: Once per hour.
-
POP Email Import Cron
- For importing support emails via the POP3 protocol.
- Example command:
*/5 * * * * php -q /path/to/pop.php
- Note: Email piping is a better alternative for support ticket automation.
Customizing Cron Tasks
WHMCS allows customization of the cron command with arguments and options to control task execution. Here's how:
-
Available Arguments
all
: Run all due automation tasks (default).do
: Run only specified tasks. Example:*/5 * * * * php -q /path/to/cron.php do --AutoSuspensions
skip
: Skip specified tasks. Example:*/5 * * * * php -q /path/to/cron.php skip --DomainRenewalNotices
list
: List all available arguments.help
: Display help for arguments or tasks.
-
Options for Advanced Customization
--force
: Force execution of tasks regardless of schedule.-v
,-vv
,-vvv
: Set verbosity levels for output.--email-report
: Send a detailed email report after cron execution.
-
Custom Task Scheduling
To execute specific tasks at different times:- Main cron skips some tasks:
*/5 * * * * php -q /path/to/cron.php skip --TicketEscalations --AutoSuspensions
- Separate cron for specific tasks:
- Ticket escalations during business hours:
0 9,10,11,12,13,14,15,16 * * 1-5 php -q /path/to/cron.php do --TicketEscalations
- Automatic suspensions on weekday mornings:
0 9 * * 1-5 php -q /path/to/cron.php do --AutoSuspensions
- Ticket escalations during business hours:
- Main cron skips some tasks:
Security Best Practices
-
Secure the Cron Directory
Move thecrons
directory outside the public document root to prevent unauthorized access. -
Restrict Cron Access
Use server-level authentication or IP restrictions for cron access.
HTTP Invocation
If your hosting environment doesn’t support direct cron jobs, use HTTP requests to invoke the cron:
- Example GET request:
GET http://www.example.com/admin/cron.php?command=skip&options=DomainRenewalNotices,TicketEscalations
Tasks Overview
Below are common WHMCS tasks and their frequencies:
Task | Description | Frequency |
---|---|---|
--AddLateFees |
Apply late fees to overdue invoices. | Daily |
--DomainRenewalNotices |
Send domain renewal notices. | Daily |
--CreateInvoices |
Generate new invoices. | Daily |
--TicketEscalations |
Process ticket escalation rules. | As often as 3 mins |
--AutoSuspensions |
Suspend overdue services. | Daily |
--DatabaseBackup |
Backup the database. | Daily |
For more detailed scheduling, see WHMCS’s official documentation.
Conclusion
Properly configuring WHMCS cron settings ensures efficient automation and smooth system operation. By understanding and customizing tasks to your needs, you can optimize your WHMCS installation while maintaining security and performance. For advanced scenarios, consult WHMCS Developer Documentation or your hosting provider for assistance.