Updated: 12 November 2026 · Applies to: PHP 8.4 CLI with cron 3.0pl1 on Debian 13; cPanel Cron Jobs
To make a cron job use your own php.ini, call PHP with the -c option followed by the path to that file, then the script:
/usr/bin/php -c /home/alice/public_html/php.ini /home/alice/public_html/cron.php
Replace alice with your hosting account username and the paths with your own. Cron jobs run the command line version of PHP, which reads its own php.ini, not the settings your website uses, so -c is how you give a scheduled script the same limits (memory, time zone, execution time) as your site.
Step 1: create the php.ini
Put only the settings you need in it, for example:
memory_limit = 512M max_execution_time = 300 date.timezone = Asia/Kolkata
Keep the file outside your public web folder if you can (for example /home/alice/php-cron.ini), so visitors cannot download it.
Step 2: find the full path to PHP
Cron needs absolute paths. On a VPS or dedicated server run:
which php
On Debian and Ubuntu this gives /usr/bin/php. On cPanel servers each installed PHP version has its own binary, for example /opt/cpanel/ea-php83/root/usr/bin/php for PHP 8.3; list the versions with ls /opt/cpanel/ and pick the one your site uses. Older guides, including the earlier version of this article, use /usr/local/bin/php. Check any path with -v before you rely on it:
/opt/cpanel/ea-php83/root/usr/bin/php -v
Step 3: add the cron job
In cPanel, open Advanced › Cron Jobs, choose the schedule and paste the command into Command (step by step in Cron Jobs in cPanel: Add, View, Edit and Delete). On a server with SSH, run crontab -e and add a line like this, which runs every 15 minutes and keeps a log:
*/15 * * * * /usr/bin/php -c /home/alice/php-cron.ini /home/alice/public_html/cron.php >> /home/alice/cron.log 2>&1
More on the crontab format: How to Edit Cron Jobs in Linux with the crontab Command.
Step 4: check that PHP loaded your file
Add this line to the script (or a test script) and look at the cron log:
<?php
echo date('c'), ' memory_limit=', ini_get('memory_limit'), ' tz=', date_default_timezone_get(), ' ini=', php_ini_loaded_file(), PHP_EOL;
In our test the same script printed this without -c:
2026-11-12T02:52:49+00:00 memory_limit=-1 tz=UTC ini=/etc/php/8.4/cli/php.ini
And this from the cron job with -c:
2026-11-12T08:25:01+05:30 memory_limit=512M tz=Asia/Kolkata ini=/home/alice/public_html/php.ini
You can also ask PHP directly which file it loads:
php -c /home/alice/php-cron.ini --ini
The line Loaded Configuration File must show your file.
Things to know about -c
- It replaces the main php.ini, it does not add to it. Settings you leave out fall back to PHP's built-in defaults, not to the server's php.ini. The extension files in the scan folder (for example
/etc/php/8.4/cli/conf.d/) are still loaded, so extensions such as mysqli or curl keep working. - A wrong path fails silently. When we pointed
-cat a file that did not exist, PHP gave no error, loaded no php.ini at all and used the defaults (memory_limit128M). Always check with Step 4. - A folder works too.
-c /home/alice/public_html/loadsphp.inifrom that folder. - For one or two values, use -d instead.
-dchanges a single setting and keeps everything else from the normal php.ini:
/usr/bin/php -d memory_limit=1G /home/alice/public_html/cron.php
- Silence the email. cPanel sends the job's output to the Cron Email address. To stop that for one job, redirect the output to a log file as shown above, or to
/dev/null 2>&1(see How to Update a Cronjob E-mail Address?).
Whether you can change PHP settings on shared hosting, and how: Do you allow access to edit php.ini file?
Official documentation: PHP command line options, cPanel Cron Jobs.