Difference between revisions of "Crons"

From WHMCS Documentation

(Setting up the Cron Tasks)
Line 54: Line 54:
 
More information on moving the crons folder can be found in the [[Custom Crons Directory|Custom Crons Directory article]].
 
More information on moving the crons folder can be found in the [[Custom Crons Directory|Custom Crons Directory article]].
  
==Option Flags==
+
==System Cron==
  
Passing in option flags to the System Cron process allows you to customise the actions that get performed.  By default, all actions will run but you can pass in any of the flags below to skip or only perform certain tasks.
+
The system cron (''crons/cron.php'') automates tasks within WHMCS.  This script can be executed with a number of optional values.  This allows very specific control of the tasks performed and the output generated by the scriptFor most installations, a simple entry that invokes the System Cron script (''crons/cron.php'') is all that is needed.
  
*'''affcommissions''' - Calculate affiliate commissions
+
===Input===
*'''affreports''' - Send affiliate reports on the first day of the month only
 
*'''backups''' - Generate WHMCS database backup
 
*'''cancelrequests''' - Process cancellation requests
 
*'''ccexpirynotices''' - Send credit card expiration notices
 
*'''ccprocessing''' - Process credit card payments
 
*'''clientstatussync''' - Change client statuses (Active, Inactive, Closed)
 
*'''closetickets''' - Auto-close answered tickets
 
*'''domainrenewalnotices''' - Send upcoming domain renewal notice emails
 
*'''emailmarketing''' - Send email marketer emails
 
*'''escalations''' - Perform ticket escalation rules
 
*'''fixedtermterminations''' - Terminate fixed-term products due today
 
*'''invoicereminders''' - Send invoice payment reminder emails
 
*'''invoices''' - Generate due invoices
 
*'''latefees''' - Apply late fees to overdue invoices
 
*'''overagesbilling''' - Generate overage invoices on the last day of the month only
 
*'''suspensions''' - Suspend overdue accounts
 
*'''terminations''' - Terminate overdue accounts
 
*'''updatepricing''' - Update product prices based upon the currency base conversion rates
 
*'''updaterates''' - Update currency base conversion rates
 
*'''usagestats''' - Update usage statistics from the server
 
*'''skip_report''' - Do not send the WHMCS Cron Job Activity email
 
  
===How to use Option Flags===
+
The system cron script has the following argument input structure:
Flags are passed in by simply appending them to the cron command. All the flags can be preceded with do_ or skip_. When running with do_, the cron will only complete the actions listed, everything else will be skipped. When using skip_, WHMCS will run all other commands except those specified to be skipped.
 
  
<div class="docs-alert-info">
+
<div class="source-cli">cron.php [<command> [options]]</div>
<span class="title">Note:</span><br />Skipping or doing functions will not stop the [[Hooks:System|cron job hooks]] from running. These will run any time the cron.php file is accessed, irrespective of the number of actions to be completed.
 
</div>
 
  
Option flags should be specified after the cron path.
+
The script also provides backwards capability for input options available prior to WHMCS v7.1:
  
====Examples====
+
<div class="source-cli">cron.php [legacy_option_flags]</div>
  
Skip credit card processing with the following cron command:
+
Mixing of legacy option flags with the new argument options is not supported and will not work.
 +
 
 +
===Commands===
 +
 
 +
The cron.php command line script has 3 essential commands:
 +
 
 +
* '''all''' - attempt to perform all due automation tasks.  If no input is provided, this command is assumed.
 +
* '''skip''' - perform all tasks, just like the '''all''' command, but exclude those specified in the input
 +
* '''do''' - only perform, unconditionally, the task(s) specified in the input options
 +
 
 +
There are two supporting commands:
 +
 
 +
* '''help''' - provides usage help & options for the command specified
 +
* '''list''' - list all possible commands
 +
 
 +
===Options===
 +
 
 +
Each command has its own set of options which can be view with the ''help <command>'' input syntax
 +
 
 +
====Additional Options====
 +
 
 +
* -f, --force
 +
** Force the execution of tasks, regardless of "due" or "in progress" state
 +
* -v, -vv, -vvv
 +
** Verbosity of command line output
 +
* --email-report=[1|0]
 +
** Force send a digest report of work performed during execution.  During the normal "daily" run, this is set to an implicit value of "1".  In all other cases, the implicit value is "0"
 +
* -V, --version
 +
** Output the WHMCS version and exits
 +
* --no-ansi
 +
** Strip any non-printing command line markup (used for color output)
 +
* -h, --help
 +
** Print help for a command; same as the '''help''' command itself
 +
 
 +
===Output===
 +
 
 +
The System Cron will not generate any success console output by default.  Use the verbosity options if you require progressive completion information while attending the manual execution of System Cron invocation.
 +
 
 +
The System Cron will, by default, generate a Digest Email Report when performing the "Daily" group of tasks.  This report can be forcibly generated for any particular invocation with the ''--email-report=1'' report.  The Digest Email Report will only contain information related to that execution and will not contain aggregate information from prior executions.  Please visit the [[Automation Status]] page in your Admin area to get an overview of daily aggregated work.
 +
 
 +
===Tasks===
 +
 
 +
All routines of system cron (''cron.php'') are tasks.  Most tasks are daily, and should only be run once a day.  Some tasks benefit from running multiple times a day, such as ticket escalations or checking for WHMCS Updates.  Other tasks should only run once a month, such as calculating overage usage and generating the respective invoices.
 +
 
 +
====Task Options for '''skip''' & '''do'''====
 +
 
 +
When performing a '''skip''' or '''do''' command, you can itemize which tasks are excluded or included respectively.
 +
Below is a table that itemizes these task options, as well as their normal frequency.
 +
 
 +
{| class="wikitable"
 +
|-
 +
! scope="col" style="width:30%"| Option
 +
! scope="col" style="width:20%"| Legacy Option
 +
! scope="col" style="width:40%"| Description
 +
! scope="col" style="width:10%"| Frequency
 +
|-
 +
| --CurrencyUpdateExchangeRates
 +
| updaterates
 +
| Update Currency Exchange Rates
 +
| Daily
 +
|-
 +
| --CurrencyUpdateProductPricing
 +
| updatepricing
 +
| Update Product Prices for Current Rates
 +
| Daily
 +
|-
 +
| --CreateInvoices
 +
| invoices
 +
| Generate Invoices
 +
| Daily
 +
|-
 +
| --AddLateFees
 +
| latefees
 +
| Apply Late Fees
 +
| Daily
 +
|-
 +
| --ProcessCreditCardPayments
 +
| ccprocessing
 +
| Process Credit Card Charges
 +
| Daily
 +
|-
 +
| --InvoiceReminders
 +
| invoicereminders
 +
| Generate daily reminders for unpaid and overdue invoice
 +
| Daily
 +
|-
 +
| --DomainRenewalNotices
 +
| domainrenewalnotices
 +
| Processing Domain Renewal Notices
 +
| Daily
 +
|-
 +
| --CancellationRequests
 +
| cancelrequests
 +
| Process Cancellation Requests
 +
| Daily
 +
|-
 +
| --AutoSuspensions
 +
| suspensions
 +
| Processing Overdue Suspensions
 +
| Daily
 +
|-
 +
| --AutoTerminations
 +
| terminations
 +
| Process Overdue Terminations
 +
| Daily
 +
|-
 +
| --FixedTermTerminations
 +
| fixedtermterminations
 +
| Process Fixed Term Terminations
 +
| Daily
 +
|-
 +
| --CloseInactiveTickets
 +
| closetickets
 +
| Auto Close Inactive Tickets
 +
| Daily
 +
|-
 +
| --AffiliateCommissions
 +
| affcommissions
 +
| Process Delayed Affiliate Commissions
 +
| Daily
 +
|-
 +
| --AffiliateReports
 +
| affreports
 +
| Send Monthly Affiliate Reports
 +
| Monthly
 +
|-
 +
| --EmailMarketer
 +
| emailmarketing
 +
| Process Email Marketer Rules
 +
| Daily
 +
|-
 +
| --CreditCardExpiryNotices
 +
| ccexpirynotices
 +
| Sending Credit Card Expiry Reminders
 +
| Monthly
 +
|-
 +
| --UpdateServerUsage
 +
| usagestats
 +
| Updating Disk & Bandwidth Usage Stats
 +
| Daily
 +
|-
 +
| --OverageBilling
 +
| overagesbilling
 +
| Process Overage Billing Charges
 +
| Monthly
 +
|-
 +
| --AutoClientStatusSync
 +
| clientstatussync
 +
| Synchronise Client Status
 +
| Daily
 +
|-
 +
| --UpdateDomainExpiryStatus
 +
| n/a
 +
| Update Domain Expiry Status
 +
| Daily
 +
|-
 +
| --TicketEscalations
 +
| escalations
 +
| Process and escalate tickets per any Escalation Rules
 +
| As soon as every 3 minutes
 +
|-
 +
| --CheckForWhmcsUpdate
 +
| n/a
 +
| Check for WHMCS Software Updates
 +
| As soon as every 8 hours
 +
|-
 +
| --DatabaseBackup
 +
| backups
 +
| Create a database backup and deliver via FTP or email
 +
| Daily
 +
|-
 +
|}
 +
 
 +
====Types====
 +
 
 +
There are two types of tasks:
 +
* '''Application''': Advances state of client data, such as orders, billing, and provisioning
 +
* '''System''': Provides software related functionality, such as generating backups or performing database normalization.
 +
** The "DatabaseBackup" task is the only task option of the '''System''' type which can be included/excluded from execution.  All other '''System''' type task options will be performed explicitly as required by WHMCS and thus do not have option flags.
 +
 
 +
====Tasks & --force Option====
 +
 
 +
The "--force" option does exactly that...it will force execute ''any'' application tasks (respective of the command ['''all''', '''skip''', '''do''']) regardless if the task is suppose to run once a day, a month, or at a time other than now.
 +
 
 +
* The '''all''' command with the "–force" flag will execute all application tasks, as if each one were due exactly now.
 +
* The '''skip''' command with the "--force" will first exclude the specified tasks (i.e., the ones provided as task option flags) and then operate on all other tasks as if each were due exactly now, similar to the '''all''' command.
 +
* The '''do''' command is designed to only run the tasks specified (i.e., the ones provided as task option flags) and to run them immediately, thus the "-–force" option is always implied and is not a valid option.
 +
* The "--force" option has no effect on '''System''' type tasks (except "DatabaseBackup")
 +
* The "--force" option has no effect on whether the Daily Digest Email Report is sent, that is controlled via the --email-report option.
 +
 
 +
====Advanced Task Scheduling====
 +
 
 +
In some environments or use-cases, having fine-grained control of one or more tasks is important.  This is possible through a combination of multiple '''do''' and '''skip''' crontab entries.
 +
Tasks performed as part of a '''do''' command will not have their internal scheduling tracking modified.  This is to ensure the integrity of a normal invocation of the System Cron.
 +
If you want a particular task to only execute on a particular schedule, create a '''do''' command for that task and alter your main System Cron invocation to '''skip''' that task (all other non-itemized task will be performed on the WHMCS schedule in this '''skip''').
 +
Likewise, if you never wish to have a particular task executed, alter your System Cron entry to be a '''skip''' command with the option for that particular task.
 +
 
 +
===Hook Points===
 +
 
 +
The System Cron has six hook events:
 +
 
 +
* PreCronJob
 +
** Fires only during the daily cron run
 +
** Is invoked before any tasks are executed
 +
** Registered hooks receive no parameter arguments
 +
* PreAutomationTask
 +
** Is invoked before each Application task
 +
** Registered hooks receive one parameter argument:
 +
*** The task object that is about to be executed, which adheres to WHMCS\Scheduling\Task\TaskInterface
 +
*** The return value of this hook is not inspected.  However, if an exception is thrown, the task will not be executed, be marked as incomplete, and iteration to the next task will commence
 +
* PostAutomationTask
 +
** Is invoked after each Application task
 +
** Registered hooks receive two parameter arguments:
 +
*** The task object that was just executed, which adheres to WHMCS\Scheduling\Task\TaskInterface
 +
*** The boolean state if the task executed without throwing an Exception
 +
*** The return value of this hook is not inspected.  Any Exception thrown will be discarded
 +
* DailyCronJobEmail
 +
** Fires during the daily cron run or when --email-report=1 is specified
 +
** Is invoked after all Application tasks are executed, immediate prior to the DailyCronJob hook
 +
** If a registered hook returns true, the digest email report will not be sent
 +
** Registered hooks receive no parameter arguments
 +
* DailyCronJob
 +
** Fires only during the daily cron run
 +
** Is invoked after all Application tasks are executed, immediate proceeding the DailyCronJobEmail hook
 +
** Register hooks receive no parameter arguments
 +
* AfterCronJob
 +
** Fires only during the daily cron run
 +
** Is invoked after all Application & System tasks are executed, just prior to script termination
 +
** Registered hooks receive no parameter arguments
 +
 
 +
===Example Crontab Entries===
 +
 
 +
Below are examples that demonstrate the flexibility of the System Cron input options and how you could craft your crontab entry.  For most WHMCS installation, you should just have one entry (Ex. 1).
 +
If you wish to disable certain tasks entirely, consider looking at the related functionality's documentation first to understand how your may be able optimize your WHMCS settings from the administration area and potential avoid unnecessary crontab entries.
 +
 
 +
Ex 1. Standard System Cron entry:
  
 
<div class="source-cli"><nowiki>
 
<div class="source-cli"><nowiki>
php -q /path/to/cron.php skip_ccprocessing
+
*/5 * * * * php -q /path/to/cron.php
 
</nowiki></div>
 
</nowiki></div>
  
Perform automatic ticket closure and usage stats updates only by using the following cron command:
+
Ex 2. Explicit entry to perform all scheduled task if they are due (will behave the same as Ex. 1):
  
 
<div class="source-cli"><nowiki>
 
<div class="source-cli"><nowiki>
php -q /path/to/cron.php do_closetickets do_usagestats
+
*/5 * * * * php -q /path/to/cron.php all
 
</nowiki></div>
 
</nowiki></div>
  
Or alternatively as a web based request as follows:
+
Ex 3. Always skip sending domain renewal notices, but perform all other tasks as normal if they are due:
  
 
<div class="source-cli"><nowiki>
 
<div class="source-cli"><nowiki>
GET http://www.yourdomain.com/admin/cron.php?do_closetickets=1&do_usagestats=1
+
*/5 * * * * php -q /path/to/cron.php skip --DomainRenewalNotices
 
</nowiki></div>
 
</nowiki></div>
  
You can specify as many option flags in a single cron command as you require.
+
Ex 4. Always skip ticket escalations and auto suspensions.  Process ticket escalations Monday-Friday during business hours, at the top of the hour, and auto suspension Monday-Friday at the start of business:
  
==System Cron Frequency==
+
<div class="source-cli"><nowiki>
 +
*/5 * * * * php -q /path/to/cron.php skip --TicketEscalations --AutoSuspensions
 +
<br/>
 +
0 9,10,11,12,13,14,15,16 * * 1-5 php -q /path/to/cron.php do --TicketEscalations
 +
<br/>
 +
0 9 * * 1-5 php -q /path/to/cron.php do --AutoSuspensions
 +
</nowiki></div>
  
WHMCS 7.0 introduced a new scheduling system that allows WHMCS to track and ensure that scheduled tasks are not being performed more frequently than desired.
+
Ex 5. In some hosting environments, direct crontab entries are not permitted. The System Cron can be invoked through an HTTP request (provided the script is accessible within the docroot)
 +
The follow demonstrates performing all tasks except DomainRenewalNotices and TicketEscalations
  
As a result, where previously the system cron was intended to be configured to only be invoked once per day, now the system cron should be configured to run more frequently. We recommend configuring it to be invoked every 5 minutes. If your web host does not allow you to perform crons at this level of frequency, you should configure it to run as frequently as your web hosting provider permits.
+
<div class="source-cli"><nowiki>
 
+
GET http://www.yourdomain.com/admin/cron.php?command=skip&options=DomainRenewalNotices,TicketEscalations
In Version 7.0, this allows us to be able to perform routine tasks and maintenance items more frequently than once per day as required.  One such task is designed to check if a new update is available as part of the [[Automatic Updater]].
+
</nowiki></div>
 
 
In future, you will see the use of the scheduler increasing to deliver improved workflows and automation across the product, as well as transitioning of tasks that can be offloaded to the scheduler as a background process to deliver better front-end performance.
 
  
 
==Legacy Cron File Locations==
 
==Legacy Cron File Locations==

Revision as of 15:47, 14 December 2016

Cron tasks must be created to automate tasks within WHMCS.

Cron is the name given to a system daemon used to execute tasks (in the background) at designated times. WHMCS has a number of files that are required to be run on a periodic basis in this way. All these files are located in the crons directory.

Setting up the Cron Tasks

System Cron

The system cron automates tasks within WHMCS. It should be configured as follows:

VersionSystem Cron Frequency
WHMCS 6.3.x and earlierOnce per day
WHMCS 7.0 and laterEvery 5 minutes, or as frequently as your web hosting provider allows

Sample Cron Command

*/5 * * * * php -q /home/username/crons/cron.php

You can find a copy&paste ready command with the path specific for your setup by navigating to Setup > Automation Settings within your WHMCS installation and copying the command from the "Create the following Cron Job using PHP" field.

Most web hosting control panels provide a simple user interface for creating cron jobs. We have guides and documentation for most popular control panels available here.

Domain Sync Cron

This cron task monitors for incoming domain transfers and synchronises expiry date changes made directly at a registrar. We recommend running this no more frequently than once every couple of days. Learn more...

Sample Cron Command

0 3 */2 0 0 php -q /home/username/crons/domainsync.php

The above example will run every 2 days at 3am.

POP Email Import Cron

This cron task is only required if you wish to import emails to the support queue via the POP3 protocol (we recommend using Email Piping wherever possible). If required, this should be configured to run every 5 minutes.

Sample Cron Command

*/5 * * * * php -q /home/username/crons/pop.php

The above example will run the POP3 email import task every 5 minutes.

Secure The Crons Directory

The crons folder may be moved to any place above or below the docroot.

We recommend moving it to a non-public directory above your web root to prevent web based access.

More information on moving the crons folder can be found in the Custom Crons Directory article.

System Cron

The system cron (crons/cron.php) automates tasks within WHMCS. This script can be executed with a number of optional values. This allows very specific control of the tasks performed and the output generated by the script. For most installations, a simple entry that invokes the System Cron script (crons/cron.php) is all that is needed.

Input

The system cron script has the following argument input structure:

cron.php [<command> [options]]

The script also provides backwards capability for input options available prior to WHMCS v7.1:

cron.php [legacy_option_flags]

Mixing of legacy option flags with the new argument options is not supported and will not work.

Commands

The cron.php command line script has 3 essential commands:

  • all - attempt to perform all due automation tasks. If no input is provided, this command is assumed.
  • skip - perform all tasks, just like the all command, but exclude those specified in the input
  • do - only perform, unconditionally, the task(s) specified in the input options

There are two supporting commands:

  • help - provides usage help & options for the command specified
  • list - list all possible commands

Options

Each command has its own set of options which can be view with the help <command> input syntax

Additional Options

  • -f, --force
    • Force the execution of tasks, regardless of "due" or "in progress" state
  • -v, -vv, -vvv
    • Verbosity of command line output
  • --email-report=[1|0]
    • Force send a digest report of work performed during execution. During the normal "daily" run, this is set to an implicit value of "1". In all other cases, the implicit value is "0"
  • -V, --version
    • Output the WHMCS version and exits
  • --no-ansi
    • Strip any non-printing command line markup (used for color output)
  • -h, --help
    • Print help for a command; same as the help command itself

Output

The System Cron will not generate any success console output by default. Use the verbosity options if you require progressive completion information while attending the manual execution of System Cron invocation.

The System Cron will, by default, generate a Digest Email Report when performing the "Daily" group of tasks. This report can be forcibly generated for any particular invocation with the --email-report=1 report. The Digest Email Report will only contain information related to that execution and will not contain aggregate information from prior executions. Please visit the Automation Status page in your Admin area to get an overview of daily aggregated work.

Tasks

All routines of system cron (cron.php) are tasks. Most tasks are daily, and should only be run once a day. Some tasks benefit from running multiple times a day, such as ticket escalations or checking for WHMCS Updates. Other tasks should only run once a month, such as calculating overage usage and generating the respective invoices.

Task Options for skip & do

When performing a skip or do command, you can itemize which tasks are excluded or included respectively. Below is a table that itemizes these task options, as well as their normal frequency.

Option Legacy Option Description Frequency
--CurrencyUpdateExchangeRates updaterates Update Currency Exchange Rates Daily
--CurrencyUpdateProductPricing updatepricing Update Product Prices for Current Rates Daily
--CreateInvoices invoices Generate Invoices Daily
--AddLateFees latefees Apply Late Fees Daily
--ProcessCreditCardPayments ccprocessing Process Credit Card Charges Daily
--InvoiceReminders invoicereminders Generate daily reminders for unpaid and overdue invoice Daily
--DomainRenewalNotices domainrenewalnotices Processing Domain Renewal Notices Daily
--CancellationRequests cancelrequests Process Cancellation Requests Daily
--AutoSuspensions suspensions Processing Overdue Suspensions Daily
--AutoTerminations terminations Process Overdue Terminations Daily
--FixedTermTerminations fixedtermterminations Process Fixed Term Terminations Daily
--CloseInactiveTickets closetickets Auto Close Inactive Tickets Daily
--AffiliateCommissions affcommissions Process Delayed Affiliate Commissions Daily
--AffiliateReports affreports Send Monthly Affiliate Reports Monthly
--EmailMarketer emailmarketing Process Email Marketer Rules Daily
--CreditCardExpiryNotices ccexpirynotices Sending Credit Card Expiry Reminders Monthly
--UpdateServerUsage usagestats Updating Disk & Bandwidth Usage Stats Daily
--OverageBilling overagesbilling Process Overage Billing Charges Monthly
--AutoClientStatusSync clientstatussync Synchronise Client Status Daily
--UpdateDomainExpiryStatus n/a Update Domain Expiry Status Daily
--TicketEscalations escalations Process and escalate tickets per any Escalation Rules As soon as every 3 minutes
--CheckForWhmcsUpdate n/a Check for WHMCS Software Updates As soon as every 8 hours
--DatabaseBackup backups Create a database backup and deliver via FTP or email Daily

Types

There are two types of tasks:

  • Application: Advances state of client data, such as orders, billing, and provisioning
  • System: Provides software related functionality, such as generating backups or performing database normalization.
    • The "DatabaseBackup" task is the only task option of the System type which can be included/excluded from execution. All other System type task options will be performed explicitly as required by WHMCS and thus do not have option flags.

Tasks & --force Option

The "--force" option does exactly that...it will force execute any application tasks (respective of the command [all, skip, do]) regardless if the task is suppose to run once a day, a month, or at a time other than now.

  • The all command with the "–force" flag will execute all application tasks, as if each one were due exactly now.
  • The skip command with the "--force" will first exclude the specified tasks (i.e., the ones provided as task option flags) and then operate on all other tasks as if each were due exactly now, similar to the all command.
  • The do command is designed to only run the tasks specified (i.e., the ones provided as task option flags) and to run them immediately, thus the "-–force" option is always implied and is not a valid option.
  • The "--force" option has no effect on System type tasks (except "DatabaseBackup")
  • The "--force" option has no effect on whether the Daily Digest Email Report is sent, that is controlled via the --email-report option.

Advanced Task Scheduling

In some environments or use-cases, having fine-grained control of one or more tasks is important. This is possible through a combination of multiple do and skip crontab entries. Tasks performed as part of a do command will not have their internal scheduling tracking modified. This is to ensure the integrity of a normal invocation of the System Cron. If you want a particular task to only execute on a particular schedule, create a do command for that task and alter your main System Cron invocation to skip that task (all other non-itemized task will be performed on the WHMCS schedule in this skip). Likewise, if you never wish to have a particular task executed, alter your System Cron entry to be a skip command with the option for that particular task.

Hook Points

The System Cron has six hook events:

  • PreCronJob
    • Fires only during the daily cron run
    • Is invoked before any tasks are executed
    • Registered hooks receive no parameter arguments
  • PreAutomationTask
    • Is invoked before each Application task
    • Registered hooks receive one parameter argument:
      • The task object that is about to be executed, which adheres to WHMCS\Scheduling\Task\TaskInterface
      • The return value of this hook is not inspected. However, if an exception is thrown, the task will not be executed, be marked as incomplete, and iteration to the next task will commence
  • PostAutomationTask
    • Is invoked after each Application task
    • Registered hooks receive two parameter arguments:
      • The task object that was just executed, which adheres to WHMCS\Scheduling\Task\TaskInterface
      • The boolean state if the task executed without throwing an Exception
      • The return value of this hook is not inspected. Any Exception thrown will be discarded
  • DailyCronJobEmail
    • Fires during the daily cron run or when --email-report=1 is specified
    • Is invoked after all Application tasks are executed, immediate prior to the DailyCronJob hook
    • If a registered hook returns true, the digest email report will not be sent
    • Registered hooks receive no parameter arguments
  • DailyCronJob
    • Fires only during the daily cron run
    • Is invoked after all Application tasks are executed, immediate proceeding the DailyCronJobEmail hook
    • Register hooks receive no parameter arguments
  • AfterCronJob
    • Fires only during the daily cron run
    • Is invoked after all Application & System tasks are executed, just prior to script termination
    • Registered hooks receive no parameter arguments

Example Crontab Entries

Below are examples that demonstrate the flexibility of the System Cron input options and how you could craft your crontab entry. For most WHMCS installation, you should just have one entry (Ex. 1). If you wish to disable certain tasks entirely, consider looking at the related functionality's documentation first to understand how your may be able optimize your WHMCS settings from the administration area and potential avoid unnecessary crontab entries.

Ex 1. Standard System Cron entry:

*/5 * * * * php -q /path/to/cron.php

Ex 2. Explicit entry to perform all scheduled task if they are due (will behave the same as Ex. 1):

*/5 * * * * php -q /path/to/cron.php all

Ex 3. Always skip sending domain renewal notices, but perform all other tasks as normal if they are due:

*/5 * * * * php -q /path/to/cron.php skip --DomainRenewalNotices

Ex 4. Always skip ticket escalations and auto suspensions. Process ticket escalations Monday-Friday during business hours, at the top of the hour, and auto suspension Monday-Friday at the start of business:

*/5 * * * * php -q /path/to/cron.php skip --TicketEscalations --AutoSuspensions <br/> 0 9,10,11,12,13,14,15,16 * * 1-5 php -q /path/to/cron.php do --TicketEscalations <br/> 0 9 * * 1-5 php -q /path/to/cron.php do --AutoSuspensions

Ex 5. In some hosting environments, direct crontab entries are not permitted. The System Cron can be invoked through an HTTP request (provided the script is accessible within the docroot) The follow demonstrates performing all tasks except DomainRenewalNotices and TicketEscalations

GET http://www.yourdomain.com/admin/cron.php?command=skip&options=DomainRenewalNotices,TicketEscalations

Legacy Cron File Locations

Prior to WHMCS Version 6, the automated task files were located across various directories. Please refer to the top of this page for the new locations of the cron files.

To aide in the transition process to their new locations, Version 6.0 of WHMCS includes proxy files in the old locations that will allow all existing configured cron and piping commands to continue operating without any changes post upgrade to 6.0.

However, we encourage you to update your cron and piping commands to use the new locations at your earliest convenience.

The old locations are deprecated as of Version 6.0, and the proxy functionality will be removed in a future release. The proxy files and their proxy locations are:

  • /admin/cron.php
  • /pipe/pipe.php
  • /pipe/pop.php
If you do not require these proxy files, you can safely remove them from your installation.