Difference between revisions of "Crons"
(→System Cron Frequency) |
|||
Line 117: | Line 117: | ||
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. | 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. | ||
− | 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]]. | + | 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]]. |
+ | |||
+ | 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 14:15, 16 September 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.
Contents
Setting up the Cron Tasks
System Cron
The system cron automates tasks within WHMCS. It should be configured as follows:
Version | System Cron Frequency |
---|---|
WHMCS 6.3.x and earlier | Once per day |
WHMCS 7.0 and later | Every 5 minutes, or as frequently as your web hosting provider allows |
Sample Cron Command
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.
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
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
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.
More information on moving the crons folder can be found in the Custom Crons Directory article.
System Cron Option Flags
Passing in option flags to the 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.
- affcommissions - Calculate affiliate commissions
- 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
- 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
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.
Note:
Skipping or doing functions will not stop the 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.
Option flags should be specified after the cron path.
Examples
Skip credit card processing with the following cron command:
Perform automatic ticket closure and usage stats updates only by using the following cron command:
Or alternatively as a web based request as follows:
You can specify as many option flags in a single cron command as you require.
System Cron Frequency
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.
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.
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.
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
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