I'm trying to run a cronjob (my first time ever) but it isn't working as expected. The PHP file I'm trying to run, contains a tiny code which sends an SMS message every time it is executed. When I open the URL to the file on my browser, it works perfectly and sends the SMS message. But the cronjob doesn't.
Here's the command I use:
/usr/local/bin/ea-php56 /home/MY_USERNAME/PATH_TO_A_SUBDOMAIN/crontest.php
I wrote the command using the guide cPanel provides at the exact same page you define a cronjob. So I basically think there's no syntax error there. Needless to say I checked the timezone for the server and compared to one I set for the cronjob.
EDIT
Here's the code existing on the PHP file:
session_start();
require_once 'maincore.php'; // contains some funtions and settings
include_once INCLUDES.'SendMessage.php'; // contains required functions for sending the SMS.
//
and some other codes here to eventually send the SMS, which works flawless
//
UPDATE
Ok so, since I added that CronJob, the CPU Usage and Disk Space Usage on my hosting panel boosted to the skies. So I tried checking my error log to identify the cause.
Now let me add some more information. The maincore.php file which I mentioned, contains some functions and also the following code:
$folder_level = "";
while (!file_exists($folder_level."config.php")) { $folder_level .= "../"; }
require_once $folder_level."config.php";
define("BASEDIR", $folder_level);
There are 2 things to point out here:
- config.php file contains database information like username, password, etc.
- That code tries to find the config.php file and include it. In case it doesn't find the file, it will go back 1 folder each time and tries finding the file again in case the maincore.php was misplaced.
As it turned out, the code I just mentioned, causes an endless loop which refers to file_exists
function.
The error log contains lots of the following errors:
PHP Warning: file_exists(): open_basedir restriction in effect. File(../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../.. in /home/MY_USERNAME/PATH_TO_A_SUBDOMAIN/maincore.php
PHP Warning: file_exists(): File name is longer than the maximum allowed path length on this platform (4096): ../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../ in /home/MY_USERNAME/PATH_TO_A_SUBDOMAIN/maincore.php