如何写一个Cron Job来执行简单的php脚本? [英] How to write a Cron Job to execute simple php script?

查看:221
本文介绍了如何写一个Cron Job来执行简单的php脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的服务器上有一个简单的php脚本,并希望它每2分钟使用cron作业运行。

I have a simply php script on my server and want it to be run every 2 minutes using a cron job.

*/2 *   *   *   *   http://mydomain.com/_adder.php

命令语法错误。

我需要在脚本网址之前添加命令吗?另一种运行脚本的方法?

Do I need to add a command before the script url? Another way to run the script?

任何帮助都非常感激。

推荐答案

你可以这样做umläute建议,但作为一个本地文件,它实际上更快地从命令行php访问像这样:

you can do it as umläute suggest, but being a local file it's actually faster to access from command line php like this:

*/2 * * * * php /path/to/file/_adder.php

通过可能影响脚本的浏览器从命令行运行脚本有差异。

there are differences running a script from the command line vs via a browser that may effect the script.

您可能需要一些系统上的完整路径php

you may need the full path to php on some systems

这篇关于如何写一个Cron Job来执行简单的php脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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