> ## Documentation Index
> Fetch the complete documentation index at: https://kb.hosting.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Using a custom php.ini file for cPanel cron jobs

> Discover how to use a custom php.ini for cPanel cron jobs with code snippets, instructions, and helpful links.

This article describes how to use a custom *php.ini* file for cPanel cron jobs.

<Note>
  This article assumes that:

  * You know how to set up a cron job using cPanel. For information about how to do this, please see [this article](/docs/cron-jobs).

  * You know how to set up custom *php.ini* files. For more information about how to do this, please see [this article](/docs/custom-php-ini-files).
</Note>

## Using a custom php.ini file for cPanel cron jobs

Different *php.ini* files, and therefore different settings, are used depending on how you run a PHP script. For example, scripts run from the command line, and scripts run from a cPanel cron job, run under different environments.

To specify the exact environment for a PHP script in a cPanel cron job, you can define the path to a custom *php.ini* file. To do this, use the **-c** option. For example, the following command runs the *script.php* file using the *php.ini* file located in the user's *config* directory:

```bash theme={null}
/usr/local/bin/php -c ${HOME}/config/php.ini ${HOME}/script.php
```

<Tip>
  A common scenario where you need a custom *php.ini* file is when a script must access remote URLs. To do this, you must enable the **allow\_url\_fopen** directive. For more information about how to do this, please see [this article](/docs/setting-the-allow-url-fopen-php-directive).
</Tip>

## Related articles

* [Cron jobs](/docs/cron-jobs)

* [Run PHP scripts from cron jobs](/docs/run-php-scripts-from-cron-jobs)

* [Custom php.ini files](/docs/custom-php-ini-files)

* [Using php.ini directives](/docs/using-php-ini-directives)

* [Getting started with cPanel](/docs/getting-started-with-cpanel)

* [Accessing cPanel](/docs/accessing-cpanel)
