Question

I've a PHP based app. We've to run a PHP file (say xyz.php) once daily to send emails. We use Cron job in cPanel to run that file everyday in the morning. I've setup my email as cron email so that I get notified every time the cron job is executed. It runs perfectly in the morning - sends the data which is required correctly and I also get notified via email every morning that cron job executed successfully.

That PHP file's URL (abc.com/xyz.php) if entered in browser manually will also send emails.

Now coming to the problem part - The email IDs in the PHP file start getting emails at random times and sometimes 30-40 emails a day. The emails are incomplete and incorrect. I don't get any notification email that cron job has executed. So, my guess is the PHP file is accessed by something which triggers the emails. I've checked access logs in the cPanel but there's nothing in there.

The app is hosted on Hostgator, if that helps.

Please help. Thanks!

Was it helpful?

Solution

Some exmplanations:

  • You may have included the file in some code,
  • Someone is accessing the file (but you outed that)
  • There may be another cron job defined (it may happend if for some reason two jobs were created or someone created it by other panels, by hand with different times) - like for testing.
  • Someone may execute it manually

    1. you you must find out yourself.
    2. block it by password or totally with .htaccess
    3. check your cron settings (also for each user crontable)
    4. check logs

Also - WRITE some code into you php file that will log HOW and WHEN it was executed - that will allow you to further test what is happening.

OTHER TIPS

this may happen when you have include your abc.com/xyz.php on some other php files , which get executed when the php pages is called via browser and some part of form get executed, also you wont get mail notofications for this type of exectutions

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top