乳宁PHP脚本本地虽然任务管理器 [英] runing php scripts locally though task manager
问题描述
我在找一些建议。
Rignt现在我已经得到了一堆,我已经通过的cron预定的PHP脚本。他们在我的本地机器上运行做的东西像拉东西了MySQL数据库,并自动发送电子邮件。要运行他们,我只是在crontab中是这样的: 0 7 * * 1的/ usr / bin中/ PHP /phpscripts/script.php
我需要所有这些脚本迁移到Windows机器。我打算使用Windows任务计划程序运行脚本,但我怎么能运行的实际PHP脚本在本地?从我inderstand你需要像XAMPP运行Apache服务器?我想我需要的是在crontab中的/ usr / bin中/ PHP的一个Windows equivilent。
非常感谢
安装PHP
您不必安装 XAMMP
,您可以单独安装PHP,看看吃了Windows下的PHP安装指南:
如果您preFER安装XAMP,可以定位在的php.exe
与 -f $ C运行PHP脚本$ C>标记:
C:\\ Xampp时\\ PHP \\的php.exe -f C:\\ Xampp时\\ htdocs中\\ my_script.php
运行PHP文件
您已经安装了PHP之后,检查 PHP命令行上的Microsoft Windows手册一>有关如何运行脚本的信息。在页面有一个如何使PHP文件可执行的解释,所以你可以运行它:
C:\\ PHP脚本\\脚本-arg1 -arg2 -arg3
请确保您使用的是管理员帐户来运行该命令。否则,你可能有权限问题。在介绍更多信息使用命令行上 计划任务 到 启动 - >程序 - >附件 - >系统工具 - >计划任务
,
C:\\ PHP \\ php.exe的C:\\的Inetpub \\ wwwroot的\\博客\\的cron \\ cron_exec.php
转至表选项卡并输入时间和频率任务运行的。时间表默认为每天运行一次,并应罚款的基本用法,但随时调整需要。
字段的其他部分可以原样,除非你是一个高手,知道自己在做什么就走了。
单击OK,我们就大功告成了!
更多信息看看设立一个窗口,计划任务。
块引用>I'm looking for some advice.
Rignt now i've got a bunch of php scripts that i've scheduled through cron. They run on my local machine doing stuff like pulling stuff out of a mysql db and sending automated emails. To run them I just have something like this in crontab:
0 7 * * 1 /usr/bin/php /phpscripts/script.php
I need to migrate all of those scripts to a Windows machine. I'm planning to use the Windows Task Scheduler to run the scripts, but how can I run the actual php scripts locally? From what I inderstand you need something like xampp to run the apache server? I guess what I need is a Windows equivilent of /usr/bin/php in crontab.
Thanks very much
解决方案Installing PHP
You don't have to install
xammp
, you can install PHP alone, have a look ate the windows PHP installation guide:
- Windows Installer (PHP 5.1.0 and earlier)
- Windows Installer (PHP 5.2 and later)
- Manual Installation Steps
If you prefer installing XAMP, you can run PHP script after locating the
php.exe
with the-f
flag:C:\Xampp\php\php.exe -f C:\Xampp\htdocs\my_script.php
Running the PHP file
After you have PHP installed, check Command Line PHP on Microsoft Windows manual for information on how to run the script. On the page there is explanation of how to make the php file executable, so you could run it as:
"C:\PHP Scripts\script" -arg1 -arg2 -arg3
Make sure you are using an administrative account to run the command. Otherwise you might have permissions problems. more info at the Introduction to using PHP on the command line
Scheduling the task
Go to
Start -> Programs -> Accessories -> System Tools -> Scheduled Tasks
,
- Right-click on an empty spot in the Scheduled Task window and select New -> Scheduled Task (Also accessible via File -> New -> Scheduled Task)
- Name the new task (How about "Bill"? He looks like a Bill, doesn't he? "Mr. B. Evolution, II" It sounds so regal.)
- Double-click the new task to open the properties window (or File -> Properties)
- Under the Task tab, enter the same command that you used to test the script above. For instance, I would enter:
C:\PHP\php.exe "C:\Inetpub\wwwroot\blogs\cron\cron_exec.php"
- Go to the Schedule tab and enter when and how often the task should run. The schedule defaults to run once daily and should be fine for basic usage, but feel free to tweak as needed.
- The rest of the fields can be left as-is, unless you're an ace and know what you're doing.
- Click OK and we're done!
for more info have a look at setting up a window scheduled task.
这篇关于乳宁PHP脚本本地虽然任务管理器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!