troubleshooting Question

CRON JOB executes differently then when a file is triggered MANUALY. WHY?

Avatar of deliriumxx
deliriumxx asked on
PHPApache Web Server
16 Comments1 Solution230 ViewsLast Modified:
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
Join our community to see this answer!
Unlock 1 Answer and 16 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 16 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros