cron命令定期执行php脚本 [英] cron command to execute a php script periodically

查看:116
本文介绍了cron命令定期执行php脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Ubuntu。以前我曾经从GUI运行cron作业。
我创建了一个php脚本并将其保存在我的服务器上。
i尝试从putty执行cron,

  5 * * * * path / folder / sample.php //脚本每5分钟运行



但不起作用。





解决方案

最可靠的方法是指定解释器的路径。您还应该将5更改为* / 5(这意味着每五分钟运行一次,而不是每小时过去5分钟运行),请尝试:

  * / 5 * * * / usr / bin / php /path/to/your/script.php 


I am using Ubuntu. Earlier I used to run cron jobs from GUI. I have created a php script and saved it on my server. i tried to execute cron from putty,

5 * * * * path/folder/sample.php // script runs for every 5 mins

But it doesn't work.

Am I in the right direction?

Actually, where should be the command get executed dynamically?

解决方案

The most sure way is specify path to your interpreter. You should also change 5 to */5 (which mean run every five minutes nor than run at 5 minutes past each hour), try:

*/5 * * * /usr/bin/php /path/to/your/script.php

这篇关于cron命令定期执行php脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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