我有一个 php 脚本,想按计划运行它.我在 Windows 上使用本地 Web 服务器(WAMP 服务器)并且需要一种方法来运行 my_script.php
每 10 分钟.
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.
如何在 Windows 本地主机上的 PHP 脚本上运行 cron 作业?
How to run a cron job on a PHP script, on localhost in windows?
最近我在 Windows 7 的 localhost(WAMP 服务器)上的 php 脚本上运行 cron 作业时遇到了一些问题,当时我正在接受长期测试从 www 那里获取一些链接.
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.
您需要一个 shellscript 来长期运行,使用 Windows 任务计划程序.此外,您还需要一个批处理脚本 (script.bat) 来调用 php.exe 并运行您的 php 脚本(此处称为 my_process.php
)
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 oscriptscript.bat" & Chr(34), 0
Set WinScriptHost = Nothing
script.bat
"C:wampinphpphp5.4.12php.exe" -f "C:wampwwwwebsitemy_process.php"
现在,我们已准备好设置 Windows 任务计划程序 以在所需的时间间隔运行 shellscript.vbs:
Now, we are ready to set the Windows Task Scheduler to run shellscript.vbs at the required time interval:
C:path o
.C:path o
.这篇关于在 Windows 本地主机上的 PHP 脚本上运行 Cron 作业的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!