Move the Cron Directory

By default, the system stores cron-related items in the crons directory. We recommend moving the crons directory to a custom private directory above your web root. This will prevent web-based access and help to protect your WHMCS installation.

We recommend performing this task and other security measures immediately after installing WHMCS. For a full list, see Enhancing Security.

Move the crons Directory

When you move the crons directory, you must also update WHMCS’s configuration to use it successfully.

To do this:

1. Move the directory to the new location.

This process involves editing multiple configuration files. You can do this using the file management tools in your hosting control panel (for example, Files » File Manager in cPanel) or using the command line.

Move the entire /crons/ directory and its contents to the new location above your web root.

2. Update cron tasks and email forwarders.

If you have already configured additional cron tasks or set up email forwarders for email piping, update the associated cron commands to use the new directory path.

3. Update the cron configuration file.

If you have not already done so, rename the config.php.new file to config.php.

Open the file and locate the $whmcspath line. For example:

//$whmcspath = '/path/to/whmcs/';

Delete the two / characters at the beginning of the line and replace the path (for example, /path/to/whmcs/) with the full path to your WHMCS installation. For example:

$whmcspath = '/home/username/public_html/whmcs/';

Then, save and close the file.

4. Update the configuration.php file.

Open the configuration.php file in your WHMCS installation’s root directory.

Add the following line to the bottom of the file, where /home/username/whmcs_crons/ is the location of your new directory:

$crons_dir = '/home/username/whmcs_crons/';

Then, save and close the file.

For more information about updating the configuration.php file, see The configuration.php File.

5. Update the system cron command.

Update the cron job to use the new directory path.

For example, you can use the steps below to update the cron job in cPanel:

  1. In the cPanel interface, go to Advanced » Cron Jobs.
  2. Choose Edit for the existing cron job for the cron.php file.
  3. Update the command to use the correct new path.
  4. Click Edit Line.

Applying Upgrades and Patches

Applying updates or patches after customizing your crons directory location requires additional step. You must upload any updated crons files from the default location to your custom directory.

If you do not move the files, you will see errors and issues with WHMCS’s automation.

Last modified: June 14, 2024