乳宁PHP脚本本地虽然任务管理器 [英] runing php scripts locally though task manager

查看:300
本文介绍了乳宁PHP脚本本地虽然任务管理器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在找一些建议。

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:\\ Xampp时\\ PHP \\的php.exe -f C:\\ Xampp时\\ htdocs中\\ my_script.php

运行PHP文件

您已经安装了PHP之后,检查 PHP命令行上的Microsoft Windows手册有关如何运行脚本的信息。在页面有一个如何使PHP文件可执行的解释,所以你可以运行它:

 C:\\ PHP脚本\\脚本-arg1 -arg2 -arg3

请确保您使用的是管理员帐户来运行该命令。否则,你可能有权限问题。在介绍更多信息使用命令行上

计划任务

启动 - >程序 - >附件 - >系统工具 - >计划任务


  1. 在在计划任务窗口中的空白处单击鼠标右键,选择新建 - >计划任务(通过文件还访问 - >新建 - >计划任务)

  2. 命名新的任务(怎么样条例?他看起来像一个法案,不是吗?B.进化先生II这听起来富豪。)

  3. 双击新的任务,打开属性窗口(或文件 - >属性)

  4. 在任务选项卡,输入您用来测试上面的脚本相同的命令。举例来说,我会输入:


      

    C:\\ PHP \\ php.exe的C:\\的Inetpub \\ wwwroot的\\博客\\的cron \\ cron_exec.php


  5.   
  6. 转至表选项卡并输入时间和频率任务运行的。时间表默认为每天运行一次,并应罚款的基本用法,但随时调整需要。

  7.   
  8. 字段的其他部分可以原样,除非你是一个高手,知道自己在做什么就走了。

  9.   
  10. 单击OK,我们就大功告成了!

  11.   

  更多信息看看设立一个窗口,计划任务


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:

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,

  1. Right-click on an empty spot in the Scheduled Task window and select New -> Scheduled Task (Also accessible via File -> New -> Scheduled Task)
  2. Name the new task (How about "Bill"? He looks like a Bill, doesn't he? "Mr. B. Evolution, II" It sounds so regal.)
  3. Double-click the new task to open the properties window (or File -> Properties)
  4. 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"

  5. 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.
  6. The rest of the fields can be left as-is, unless you're an ace and know what you're doing.
  7. Click OK and we're done!

for more info have a look at setting up a window scheduled task.

这篇关于乳宁PHP脚本本地虽然任务管理器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆