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 | Frequency |
---|---|---|
--AddLateFees | Apply Late Fees | Daily |
--AffiliateCommissions | Process Delayed Affiliate Commissions | Daily |
--AffiliateReports | Send Monthly Affiliate Reports | Monthly |
--AutoClientStatusSync | Synchronise Client Status | Daily |
--AutoPruneTicketAttachments | Auto Remove Inactive Ticket Attachments. Batches of 1000 | Hourly |
--AutoSuspensions | Processing Overdue Suspensions | Daily |
--AutoTerminations | Process Overdue Terminations | Daily |
--CancellationRequests | Process cancellation requests (including requests for services that have Auto Terminate End of Cycle enabled). | Daily |
--CheckForWhmcsUpdate | Check for WHMCS Software Updates | As soon as every 8 hours |
--CloseInactiveTickets | Auto Close Inactive Tickets | Daily |
--CreateInvoices | Generate Invoices | Daily |
--CreditCardExpiryNotices | Sending Credit Card Expiry Reminders | Monthly |
--CurrencyUpdateExchangeRates | Update Currency Exchange Rates | Daily |
--CurrencyUpdateProductPricing | Update Product Prices for Current Rates | Daily |
--DataRetentionPruning | Process data retention pruning operation. | Daily |
--DatabaseBackup | Create a database backup and deliver via FTP or email | Daily |
--DomainRenewalNotices | Processing Domain Renewal Notices | Daily |
--DomainStatusSync | Processing Domain Status Syncing for Active domains. Batches of 50. | As soon as every hour |
--DomainTransferSync | Processing Domain Transfer Syncing for Pending Transfer domains | As soon as every hour |
--EmailCampaigns | Update the status of Email Campaigns and schedule emails. Batches of 50 | As soon as every 5 minutes |
--EmailMarketer | Process Email Marketer Rules | Daily |
--FixedTermTerminations | Process Fixed Term Terminations | Daily |
--InvoiceAutoCancellation | Automatically cancel old overdue unpaid invoices. 8.10+ | Daily |
--InvoiceReminders | Generate daily reminders for unpaid and overdue invoice | Daily |
--OverageBilling | Process Overage Billing Charges and Generate Invoices | Monthly |
--ProcessCreditCardPayments | Process Credit Card Charges | Daily |
--ProcessEmailQueue | Process scheduled emails within Email Campaigns. Batches of 25 | As soon as every 5 minutes |
--SslReissues | Process MarketConnect SSL certificate reissuances. v8.5+ | Daily |
--SslSync | Check validity of SSL Certificates on services and domains. Batches of 100. | Daily |
--ServerRemoteMetaData | Auto Update Server Meta Data. Displayed on Configuration () > System Settings > Servers. | Hourly |
--ServerUsageCount | Auto Update Server Usage Count. Displayed on Configuration () > System Settings > Servers. | Hourly |
--TenantUsageMetrics | Auto Update Service Usage Data. Displayed when viewing Service within Client Area. | Twice-daily |
--TicketEscalations | Process and escalate tickets per any Escalation Rules | As soon as every 3 minutes |
--UpdateDomainExpiryStatus | Update Domain Expiry Status for domains with a past Expiry Date | Daily |
--UpdateServerUsage | Updating Disk & Bandwidth Usage Stats | 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: October 30, 2024