System Cron
When you set up your WHMCS installation, you must set up the system cron to automate WHMCS’s many tasks. The system cron is a system daemon that executes tasks at designated times. WHMCS includes processes that must run on a periodic basis via the cron.
Cron Tasks
The method that you use to set up your cron jobs will depend on the type of server that you use and whether you prefer to use the command line or a control panel interface.
After you set up the cron job, you can change the time at which the daily automated actions run using Time of Day at Configuration () > System Settings > Automation Settings. You must ensure that the system cron will run during the hour that you set.
- WHMCS uses the PHP
now()
timestamp when thecron.php
script runs. This determines the current time using the value that the PHP configuration returns. - We recommend running the cron task every five minutes. WHMCS will never perform a particular task more frequently than you specify.
- Make certain that WHMCS’s configured timezone matches the server’s timezone.
When you configure WHMCS, set up the following cron tasks:
System Cron
The system cron automates tasks within WHMCS. The system uses this to automate billing, generate invoices, and perform many other actions. Configure this to run every 5
minutes, or as frequently as your hosting provider allows (at minimum, once per hour).
You can find the correct command to copy-and-paste for your WHMCS installation by going to Configuration () > System Settings > Automation Settings and clicking on the first badge:
For example: */5 * * * * php -q /home/username/crons/cron.php
POP Email Import Cron
You only need to configure this cron task if you want to import emails to the support queue via the POP3 protocol.
If you use this, configure it to run every five minutes.
For example: */5 * * * * php -q /home/username/crons/pop.php
The crons Directory
All of the files for WHMCS’s cron tasks are in the crons
directory.
You can move the crons
folder to any location above or below the document root. We recommend moving it to a private directory above your document root for better security.
System Cron Options
The system cron automates tasks within WHMCS. You can run the system cron script (crons/cron.php
) with additional options if you need additional control over the tasks that run and the script’s output.
The system cron script has the following argument input structure:
cron.php [<argument> [options]]
- Most WHMCS installations will not need these additional options.
- To pass arguments to PHP scripts, you must enable the
register_argc_argv
directive. For help, contact your hosting provider or system administrator.
Arguments
You can use the following arguments:
Argument | Description | Example |
---|---|---|
all | Attempt to perform all due automation tasks. If you do not provide input, the cron runs with this argument by default. | */5 * * * * php -q /path/to/cron.php all |
do | Only perform the tasks that you specify.
For a list of tasks, see Tasks below. | |
help | Lists help and options for the argument you specify. | |
list | Lists all possible arguments. | |
skip | Perform all tasks (in the same way as the all argument) but exclude tasks that you specify. For a list of tasks, see Tasks below. | */5 * * * * php -q /path/to/cron.php skip --DomainRenewalNotices |
help <argument>
.Options
You can use the following arguments:
Option | Description |
---|---|
-F , --force | Force the execution of tasks, regardless of whether the task is due or already in progress. |
-v , -vv , -vvv | Set the verbosity of command line output. By default, the system cron does not generate any success output. |
--email-report | Forcibly send a digest report of the actions during the run. This report contains information about that cron run and will not contain information from previous runs. During the normal daily run, this uses a default value of 1 and sends the Digest Email Report message. In all other runs, this defaults to 0 and does not send anything. For example: --email-report=1 |
-V , --version | Output the WHMCS version and exit. |
--no-ansi | Strip any non-printing command line markup (for color output). |
-h , --help | Print help for a command. This returns the same output as the help argument. |
Tasks
Most of the system cron’s tasks only need to run daily. Others, however, may benefit from running multiple times per day, like ticket escalations or checking for WHMCS updates. A few tasks only run once per month, like calculating overage usage and generating invoices.
WHMCS handles this correctly automatically for scheduled cron runs, but you can also choose tasks to run (using the do
argument) or skip (using the skip
argument) when running the cron yourself:
Option | Description | In Version | Frequency |
---|---|---|---|
--AddLateFees | Apply late fees to unpaid invoices that are past their due dates. | WHMCS 8+ | Daily |
--AffiliateCommissions | Process payment of delayed affiliate commissions. | WHMCS 8+ | Daily |
--AffiliateReports | Send monthly affiliate report emails. | WHMCS 8+ | Monthly |
--AutoClientStatusSync | Sync client statuses. | WHMCS 8+ | Daily |
--AutoPruneTicketAttachments | Remove attachments for inactive tickets. This task runs in batches of 1,000. | WHMCS 8+ | Hourly |
--AutoSuspensions | Suspend services that are due for suspension. | WHMCS 8+ | Daily |
--AutoTerminations | Terminate services that are due for termination. | WHMCS 8+ | Daily |
--CancellationRequests | Cancel services with cancellation requests (including requests for services with Auto Terminate End of Cycle enabled. | WHMCS 8+ | Daily |
--CheckForWhmcsUpdate | Check for WHMCS version updates. | WHMCS 8+ | As soon as every 8 hours |
--CloseInactiveTickets | Close inactive support tickets. | WHMCS 8+ | Daily |
--CreateInvoices | Generate invoices. | WHMCS 8+ | Daily |
--CreditCardExpiryNotices | Send expiry reminders for client credit cards. | WHMCS 8+ | Monthly |
--CurrencyUpdateExchangeRates | Update currency exchange rates. | WHMCS 8+ | Daily |
--CurrencyUpdateProductPricing | Update product prices for current currency exchange rates. | WHMCS 8+ | Daily |
--DataRetentionPruning | Automatically delete clients with the Inactive and Closed statuses. | WHMCS 8+ | Daily |
--DatabaseBackup | Create a database backup and upload it or send it in email. | WHMCS 8+ | Daily |
--DomainRenewalNotices | Send domain renewal notices. | WHMCS 8+ | Daily |
--DomainStatusSync | Sync domain statuses for domains in the Active status. This task runs in batches of 50. | WHMCS 8+ | As soon as every hour |
--DomainTransferSync | Sync domain transfers for domains in the Pending Transfer status. | WHMCS 8+ | As soon as every hour |
--EmailCampaigns | Update the statuses of email campaigns and schedule emails. This task runs in batches of 50. | WHMCS 8+ | As soon as every 5 minutes |
--EmailMarketer | Process Email Marketer rules. | WHMCS 8+ | Daily |
--FixedTermTerminations | Process fixed-term terminations. | WHMCS 8+ | Daily |
--InvoiceAutoCancellation | Automatically cancel old overdue unpaid invoices. | WHMCS 8.10+ | Daily |
--InvoiceReminders | Generate reminders for unpaid and overdue invoices. | WHMCS 8+ | Daily |
--OverageBilling | Process overage billing charges and generate related invoices. | WHMCS 8+ | Monthly |
--ProcessCreditCardPayments | Process credit card charges. | WHMCS 8+ | Daily |
--ProcessEmailQueue | Send scheduled emails for your email campaigns. This task runs in batches of 25. | WHMCS 8+ | As soon as every 5 minutes |
--ServerRemoteMetaData | Automatically update the server metadata that displays at Configuration () > System Settings > Servers. | WHMCS 8+ | Hourly |
--ServerUsageCount | Automatically update the server usage count that displays at Configuration () > System Settings > Servers. | WHMCS 8+ | Hourly |
--SslReissues | Process MarketConnect SSL certificate reissuances. | WHMCS 8.5+ | Daily |
--SslSync | Check SSL certificate validity for services and domains. This task runs in batches of 100. | WHMCS 8+ | Daily |
--TenantUsageMetrics | Update the usage data that displays when you view services in the Products/Services tab in the client profile. | WHMCS 8+ | Twice Daily |
--TicketEscalations | Process and escalate tickets according to your configured escalation rules. | WHMCS 8+ | As soon as every 3 minutes. |
--TicketScheduledActions | Attempt any scheduled actions at their scheduled execution time. | WHMCS 8.12+ | As soon as every one minute. |
--UpdateDomainExpiryStatus | Update the expiry status for domains with a past expiry date. | WHMCS 8+ | Daily |
--UpdateServerUsage | Update disk and bandwidth usage statistics. | WHMCS 8+ | Daily |
Custom Task Runs
If you want a particular task to only execute on a particular schedule, create a separate scheduled cron command that uses the do
argument for that task and alter your main System Cron command to skip that task using the skip
argument.
For example, you could schedule the first cron command below to skip ticket escalations and automatic suspensions on regular runs:
*/5 * * * * php -q /path/to/cron.php skip --TicketEscalations --AutoSuspensions
Then, you could schedule the second and third commands separately to only process ticket escalations on weekdays during business hours and only process automatic suspensions on weekday mornings:
0 9,10,11,12,13,14,15,16 * * 1-5 php -q /path/to/cron.php do --TicketEscalations
0 9 * * 1-5 php -q /path/to/cron.php do --AutoSuspensions
Invoke the Cron with an HTTP Request
In some hosting environments, you may not be able to create a crontab entry directly. Instead, you can invoke the cron command using an HTTP request.
cron.php
script is accessible within the document root.For example, the following GET
request runs the system cron, skipping the DomainRenewalNotices
and TicketEscalations
tasks.
GET http://www.example.com/admin/cron.php?command=skip&options=DomainRenewalNotices,TicketEscalations
Last modified: January 8, 2025