Difference between revisions of "Crons"
(→Legacy Cron File Locations) |
|||
Line 1: | Line 1: | ||
− | + | 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. | |
− | * /crons/cron.php | + | ==Setting up the Cron Tasks== |
− | + | ||
− | * /crons/ | + | ===System Cron=== |
− | * /crons/pop.php | + | |
+ | The system cron automates tasks within WHMCS. This should be configured to run every 5 minutes. | ||
+ | |||
+ | '''Sample Cron Command''' | ||
+ | <div class="source-cli"> | ||
+ | */5 * * * * php -q /home/username/crons/cron.php | ||
+ | </div> | ||
+ | |||
+ | You can obtain the exact command and correct path you need to use by navigating to ''Setup > Automation Settings'' within your WHMCS installation and copying the command from the "Create the following Cron Job using PHP" field. | ||
+ | |||
+ | <div class="docs-alert-success">Most web hosting control panels provide a simple user interface for creating cron jobs. Please refer to the documentation for your specific control panel for details of how to complete these steps.</div> | ||
+ | |||
+ | ===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''' | ||
+ | <div class="source-cli"> | ||
+ | 0 3 */2 0 0 php -q /home/username/crons/domainsync.php | ||
+ | </div> | ||
+ | |||
+ | ===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''' | ||
+ | <div class="source-cli"> | ||
+ | */5 * * * * php -q /home/username/crons/pop.php | ||
+ | </div> | ||
==Secure The Crons Directory== | ==Secure The Crons Directory== | ||
Line 49: | Line 77: | ||
</div> | </div> | ||
− | Option flags should be specified after the cron path. | + | Option flags should be specified after the cron path. |
+ | |||
+ | ====Examples==== | ||
+ | |||
+ | Skip credit card processing with the following cron command: | ||
<source lang="php"> | <source lang="php"> | ||
Line 55: | Line 87: | ||
</source> | </source> | ||
− | + | Perform automatic ticket closure and usage stats updates only by using the following cron command: | |
<source lang="php"> | <source lang="php"> | ||
Line 61: | Line 93: | ||
</source> | </source> | ||
− | Or alternatively as a | + | Or alternatively as a web based request as follows: |
<source lang="php"> | <source lang="php"> |
Revision as of 12:54, 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
- /5 * * * * php -q /home/username/crons/cron.php
You can obtain the exact command and correct path you need to use 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
0 3 */2 0 0 php -q /home/username/crons/domainsync.php
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
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:
php -q /path/to/cron.php skip_ccprocessing
Perform automatic ticket closure and usage stats updates only by using the following cron command:
php -q /path/to/cron.php do_closetickets do_usagestats
Or alternatively as a web based request as follows:
GET http://www.yourdomain.com/admin/cron.php?do_closetickets=1&do_usagestats=1
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: