Christian Tisell

Registered
May 24, 2019
3
0
1
Sweden
cPanel Access Level
Website Owner
Hi,

I try to run a cron job in cpanel version 78 and PHP 7.1 but have no success.

When running it from a browser it works flawlessly.
example.com/template/temp/test.php

But inside cpanel nothing happens. I even not get any *error mail* ;-)

Have tried with these different versions of code:

/usr/local/bin/php -q /home/*****/public_html/weather/template/temp/test.php

/usr/local/bin/php /home/*****/public_html/weather/template/temp/test.php

/usr/local/bin/ea-php71 /home/*****/public_html/weather/template/temp/test.php

opt/cpanel/ea-php71/root/usr/bin/php /home/*****/public_html/weather/template/temp/test.php


Nothing at all happens. If I misspell or misconfigure any of above I got an *error mail*

I have also managed to get my ISP to provide me with logs from /var/log/cron.log

But I can't see any error in these?
May 25 01:12:01 cpsrv22 CROND[7802]: (*****) CMD (/usr/local/bin/php -q /home/*****/public_html/weather/template/temp/test.php)
May 25 01:14:01 cpsrv22 CROND[12153]: (*****) CMD (/usr/local/bin/php -q /home/*****/public_html/weather/template/temp/test.php)

Why does it not work, or something happens via cron but all work via browser?

What do I do wrong?? :)

Btw ***** is my masked account name ;-)


All Best
Christian
 
Last edited by a moderator:

cPanelLauren

Product Owner II
Staff member
Nov 14, 2017
13,266
1,301
363
Houston
Is anything output to the PHP error logs? If you don't have php error logging enabled you should be able to enable it in the php.ini file in your account by adding the following:
Code:
; log PHP errors to a file
log_errors = on
error_reporting = 32767
error_log = /path/to/file
If you are unsure how to do this or this doesn't work you will need to speak to your provider about enabling it.
 

Christian Tisell

Registered
May 24, 2019
3
0
1
Sweden
cPanel Access Level
Website Owner
Hi, tnx for the answer.

I have managed to locate the error file and found some errors. It seems that it has to do with the php.ini include_path setting. ( I think!!)

This is the error I got in my log file.

Code:
[29-May-2019 23:50:01 Europe/Stockholm] PHP Warning: require(../config.php): failed to open stream: No such file or directory in /home/xxxxx/public_html/weather/template/update/update.php on line 24

[29-May-2019 23:50:01 Europe/Stockholm] PHP Fatal error: require(): Failed opening required '../config.php' (include_path='.:/opt/cpanel/ea-php71/root/usr/share/pear') in /home/xxxxx/public_html/weather/template/update/update.php on line 24

[29-May-2019 23:50:01 Europe/Stockholm] PHP Warning: require(../../config.php): failed to open stream: No such file or directory in /home/xxxxx/public_html/weather/template/plugins/meteohub/update.php on line 33

[29-May-2019 23:50:01 Europe/Stockholm] PHP Fatal error: require(): Failed opening required '../../config.php' (include_path='.:/opt/cpanel/ea-php71/root/usr/share/pear') in /home/xxxxx/public_html/weather/template/plugins/meteohub/update.php on line 33

My include_path today is
.:/opt/alt/php71/usr/share/pear

My config.php file is in the directory /home/xxxxx/public_html/weather/template

Am I right when I think I have to extend my include_path with one more path? A path to where the config.php file is.

Both these scripts have a variable called $base but it differs depending on how deep in the file structure the running scripts are

$base = "../";
and
$base = "../../";

If I'm right is it enough to put this path to the indlude_path setting
/home/xxxxx/public_html/weather/template
or do I have to put something else in the settings?

Maybe it's not include_path at all that is the problem.

I'm a newbie to this so please bear with me and my problems. :)

All the best
Christian
 
Last edited by a moderator:

cPanelLauren

Product Owner II
Staff member
Nov 14, 2017
13,266
1,301
363
Houston
The php documentation on this might be helpful: PHP: set_include_path - Manual

It might also be helpful just to confirm what's on line 24 of the file that's noted:

Code:
/home/xxxxx/public_html/weather/template/update/update.php on line 24
 

Christian Tisell

Registered
May 24, 2019
3
0
1
Sweden
cPanel Access Level
Website Owner
Hi again :)

About the scripts that have an error on line 24, it looks like this

Row Script
21 $base = "../";
22
23 // load main info
24 require($base."config.php");
25
26 // load dependencies
27 require($base."scripts/functions.php");

and so forth...

Script with error on line 33

Row Script
30 $base = "../../";
31
32 // load main info
33 require($base."config.php");
34
35 // load dependencies
36 require($base."scripts/functions.php");

Have read the man page but still not sure hot to put the path when the variable in one script is one level down and in the other two levels down. Probably it's an "error 40" and I that don't understand. :)

My Include_path look like this now
.:/opt/alt/php71/usr/share/pear:/home/xxxxx/public_html/weather/template
(what i added in blod) but still same error :-(

/Christian