Fix fatal error for inlcude path and included file not existed using include or require for cron job

When running php in cron, the include and require path may not work.

Eg. when your file has below require or include statement:

require '../includes/common.php';

You will get a fatal error when running using php-cli or php-cli in cron

# php-cli
php /home/username123/public_html/cron/mycronjob.php
# cron
* * * * * php /home/username123/public_html/cron/mycronjob.php

Error got:

Fatal error: require(): Failed opening required '../includes/common.php'
 (include_path='.:/usr/lib/php:/usr/local/lib/php') in
 /home/username123/public_html/cron/mycronjob.php on line 2

To fix this, you need to use php to set include_path attributes so when running cron it’ll set the path so the script will learn where to look for the include / require files.




require 'common.php';

My experiences of changing php cron job running by wget to php-cli /usr/bin/php

tool used to convert the cron interval to human readable time:

This is one of my real world experiences.

Lately we migrated some websites with the entire WHM and all the cron jobs running as is.

There were about 12 cron jobs running, something like below:

59 23 * * 6 /usr/bin/wget -O /dev/null “” >/dev/null 2>&1

However because of the domain and IP routing changes, we could no longer run wget for any of the php files under these domains.

So my alternative is to move these script running via wget to internally running via php-cli.

Below is the approach:

Firstly created a test cron.

SSH as root, put a small php script to output the time stamp and run as cronjob every minute as below. ( crontab -l will show this line at the bottom)
* * * * * /usr/bin/php /home/website/public_html/date_cron_test.php >> /usr/logs/date_cron_test.log 2> /dev/null
Successfully generates the log file and had correct record for outputs of each round.

Then change all the cron jobs like below

59 23 * * 6 /usr/bin/wget -O /dev/null “” >/dev/null 2>&1


59 23 * * 6 /usr/bin/php /home/somedomain/public_html/some-api-data.php >> /usr/logs/some-api-data.log 2> /dev/null

Change all the old wget ones to the /usr/bin/php php-cli ones accordingly.

Also the php needs to be set mode with x as executable, eg 755, this depends on your actual server settings.

Finally run service crond reload

It’s all set up. All we need to do is checking the cron and php log later to verify.



Manually edit vhost file on WHM-Cpanel server

Manually edit vhost file on WHM-Cpanel server

If you need to manually edit the vhost file ona server that is running WHM and cPanel then you need to edit the include files which are used to build the vhost file. The include files for each account are held in the following location:


The main file would be


Parked domains and subdomains are held in the “main” file in the same folder. For an account, “yourdomain” and the URL yourdomain,com you would edit:


After editing the file you need to run the following three commands to rebuild the vhost file.

/usr/local/cpanel/bin/apache_conf_distiller --update
 /etc/init.d/httpd restart