简体   繁体   中英

How can I schedule the execution of a PHP script on Windows

For my reminder system app I need to send emails, one day before the event . The database stores the reminders with date , time , user_id . Is there any way I can schedule an email that automatically gets sent a day before the event occurs ?

1) Create a batch file that will run the script

Open up notepad, add this command, with your own attributes:

"PATH_TO_PHP.EXE" -f "SCRIPT_TO_RUN.PHP"

So it may look like this:

"C:\Program Files (x86)\PHP\v5.3\php.exe" -f "C:\tasks\task.php")

Save this file as a .bat file (Batch file).

(OK so creating a batch file isn't completely necessary but what if you wanted to expand on this task? Right?)

2) Have task scheduler run the task

Open up Task Scheduler (You'll find it in Accessories > System Tools , or just search for 'taskschd.msc')

Create a task.

Give it a name, Create a trigger for the specified day.

Now go to the Actions tab, hit New and it should say 'Start a program' by default.

Browse to the batch file that you just made, click OK and you're done.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM