I am running a simple PHP script on my server that basically takes a file from a directory and sends it as email message to one of the email addresses that I have in a list in a TXT file.
The script works PERFECT when I trigger it manually,,, but when I schedule a CRON JOB, the script executes only partially.
The script is supposed to check if a folder containing TXT files that are sent as emails is empty. IF the directory is empty the admin gets the message that the directory is empty, however,,, when the directory is not empty it takes a file from the directory,,, sends it as email,, and removes the file from directory.
As I mentioned,,, this all happens as clockwork when I trigger the script manualy....
HOWEVER,,, when I schedule a cron job,, the cron is consistenlty reporting that the directory is empty, even when it is not empty.... What am I doing wrong,,,,
All help appreciated...
Here is what I use to check if the directory is empty:
$dir = $_SERVER['DOCUMENT_ROOT']."/mms/data/";
$isEmpty = (count(glob("$dir/*")) === 0) ? '0' : '1';
// it returns 0 when the directory is empty and returns 1 when it is not,, when I manually trigger the script