How do i run a script at set intervals in WAMP?
So i have this script schedule.php that i want to run at every 5 minutes. The script checks for something, modifies the database and sends some mails.I have WAMP server on windows 7 ultimate. I tried using windows scheduler but i think it only works for windows server and cron开发者_运维技巧 jobs works only for linux.
There are a few ways to do this, one of the ways I have succeed in the past was to make a .bat file or a PowerShell (.ps) file which can be invoked by the Windows as a Scheduled Task. I prefer this method since, on the Windows platform, you get the GUI of all your Tasks in one location and it is easy to keep track of them.
The quick and dirty solution can be found for PowerShell in this StackOverflow article but I'll paste the solution here as well:
$WshShell = new COM("WScript.Shell");
$oExec = $WshShell->Run("C:\wamp\bin\php\phpVERSIONNUMBER\php-win.exe -f C:/wamp/www/path/to/backgroundProcess.php", 0, false);
Hope this is helpful and gets you headed in the right direction.
I made a bat file containing this line
C:\wamp\bin\php\phpYOURVERSION\php-win.exe -f C:\wamp\www\PATHTOYOURSCRIPT.php
Then I scheduled this bat file to run on my desired schedule in the windows scheduler.
精彩评论