I have a php script and want to run it on an schedule. I am using local web server on windows (WAMP server) and need a way to run my_script.php
every 10 min.
How to run a cron job on a PHP script, on localhost in windows?
Cron on Windows Create your new scheduled task based on the following items: For the scheduled task's command to run, enter the path and filename for your installed web browser, followed by the address of your localhost website's cron.
- Go to Start >> Control Panel >> Scheduled Tasks >> Add Scheduled Task. - Type "Moodle Cron" as the name of the task and select "Daily" as the schedule. Click "Next". - Select "12:00 AM" as the start time, perform the task "Every Day" and choose today's date as the starting date.
recently I had sort of problems to run a cron job on a php script on localhost (WAMP server) in windows 7, when I was on a test to chronically fetch some links from www out there.
By the way I am sharing this for anyone that is on the same thing.
You will need a shellscript to run chronically, using Windows Task Scheduler. Also you will need a batch script (script.bat) to call the php.exe and run your php script (here called as my_process.php
)
shellscript.vbs
Set WinScriptHost = CreateObject("WScript.Shell") WinScriptHost.Run Chr(34) & "C:\path\to\script\script.bat" & Chr(34), 0 Set WinScriptHost = Nothing
script.bat
"C:\wamp\bin\php\php5.4.12\php.exe" -f "C:\wamp\www\website\my_process.php"
Now, we are ready to set the Windows Task Scheduler to run shellscript.vbs at the required time interval:
C:\path\to\
.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With