Crons

From WHMCS Documentation

Revision as of 02:23, 31 December 2015 by Lawrence (talk | contribs) (Legacy Cron File Locations)

All files that WHMCS requires to be run on a periodic basis are located in the crons directory. A cron is simply the name given to a system daemon used to execute desired tasks (in the background) at designated times.

At the time of writing, WHMCS has 4 such files.

  • /crons/cron.php - The System Cron
  • /crons/domainsync.php - The Domain Expiry Synchronisation Cron
  • /crons/pipe.php - The Email Piping Forwarding Script
  • /crons/pop.php - The Email Piping POP Cron

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 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. For example, to skip credit card processing, you would configure the cron command as follows:

php -q /path/to/cron.php skip_ccprocessing

To perform automatic ticket closure and usage status updating, you would configure the cron command as follows:

php -q /path/to/cron.php do_closetickets do_usagestats

Or alternatively as a browser request, like this:

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
If you do not require these proxy files, you can safely remove them from your installation.

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: