'Task Scheduler not working, (php script not executed) Windows 7

I have a local WAMP install.. and my understanding is that you can set up CRON jobs here (being Windows and all)..

I wanted to test out calling a .php script at a schedule time, using the Windows Task Scheduler.

I set up a simple .php script that sends an email (nothing more).

I tested that it works but going directly to the script in my browser (email received, no issues)

So I set about trying to configure a Scheduled Task on my Windows 7 machine:

  • Opened up Task Scheduler
  • Right clicked Task Scheduler Library > Create Task

General Tab:

  • Name: Email_Test
  • Run whether user is logged in or not (checked)

Actions Tab:

  • Action: Start a program
  • Program Script: C:\wamp\bin\php\php5.4.12\php.exe (I know I know.. I'll update to PHP 7 soon!)
  • Arguments: -f C:\wamp\www\cron_jobs/email_test.php
  • Start in: C:\wamp\www\cron_jobs\

Triggers:

  • Begin task: On a schedule

  • Daily: (setting time for a minute or two ahead of current time to test)

  • Repeat: every 5 minutes

  • Expire: Tomorrow

  • I only need it go off once a day, but wanted to put those settings in to keep testing.

I have yet to receive an email using this as a Schedule Task..

I originally had a .bat file set up as well.. but read some different tutorials that showed to do it this way? But I have no problem changing some path to a .bat file instead somewhere if that is my error/issue?

I also enabled History.. and all entries say things were successful? (Task/Action Started/Completed)

What am I doing wrong? and more so, how can I fix it? :)

Updated information:

I forgot to mention that for my WAMP/PHP install.. I am using SENDMAIL as my mailer.. perhaps this is part of the problem? DO I need to somehow allow the sendmail.exe to execute or something as well?

I do NOT want to directly use sendmail by itself.. I would prefer to use the PHP script.. eventually I want to add in a DB log, before I sent the email out.. but for now.. the PHP script ONLY has mail() function in it.

So upon reading.. I guess the php.ini file in APACHE is not the same as used in the CLI PHP execution?

I couldnt find php.ini @ C:\wamp\bin\php\php5.x.x\php.ini But I did find and update:

C:\wamp\bin\php\php5.x.x\php.ini-development & C:\wamp\bin\php\php5.x.x\php.ini-production

  • it didnt say.. but are these supposed to be renamed to be php.ini?

(although I'm not sure what those files are for.. but I made them match my php.ini file here:

C:\wamp\bin\apache\Apache2.X\bin\php.ini

Yet still.... no email arrives!

If I open script in browser.. I get email always?

(as that works fine for sending mail without issues?)



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source