Difference between revisions of "Crons"
(→Setting up the Cron Tasks) |
(→Examples) |
||
Line 83: | Line 83: | ||
Skip credit card processing with the following cron command: | Skip credit card processing with the following cron command: | ||
− | < | + | <div class="source-cli"><nowiki> |
php -q /path/to/cron.php skip_ccprocessing | php -q /path/to/cron.php skip_ccprocessing | ||
− | </ | + | </nowiki></div> |
Perform automatic ticket closure and usage stats updates only by using the following cron command: | Perform automatic ticket closure and usage stats updates only by using the following cron command: | ||
− | < | + | <div class="source-cli"><nowiki> |
php -q /path/to/cron.php do_closetickets do_usagestats | php -q /path/to/cron.php do_closetickets do_usagestats | ||
− | </ | + | </nowiki></div> |
Or alternatively as a web based request as follows: | Or alternatively as a web based request as follows: | ||
− | < | + | <div class="source-cli"><nowiki> |
GET http://www.yourdomain.com/admin/cron.php?do_closetickets=1&do_usagestats=1 | GET http://www.yourdomain.com/admin/cron.php?do_closetickets=1&do_usagestats=1 | ||
− | </ | + | </nowiki></div> |
You can specify as many option flags in a single cron command as you require. | You can specify as many option flags in a single cron command as you require. |
Revision as of 13:06, 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. This should be configured to run every 5 minutes.
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.
Sample Cron Command
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
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.
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
Setting Up the Cron Tasks
Guidance on how to setup the cron tasks or email piping command can be found in their respective documentation pages: