Home  >  Article  >  Backend Development  >  linux crontab 定时运行php文件

linux crontab 定时运行php文件

WBOY
WBOYOriginal
2016-06-23 14:03:281406browse

linux crontab 定时运行php文件

添加一个定时任务:隔一分钟执行运行一次test.php这个文件

crontab -e 

*/1 * * * * root -q  /usr/local/php/bin/php /usr/local/apache2/htdocs/test/crontab/test.php
crontab: installing new crontab
但不能一分钟运行一次,请问哪出了错?

直接命令  /usr/local/php/bin/php /usr/local/apache2/htdocs/test/crontab/test.php
是可以运行test.php文件的,但不能定时运行。

test.php代码如下
#!/usr/local/php/bin/php
        $mem = new Memcache();
        $mem->connect('192.168.4.181','11211');
        $re = $mem->add('crontab','test数据','0','60');


回复讨论(解决方案)

你乍样确定不能运行??
$mem->add('crontab','test数据','0','60');
你增加的值,只存在一分钟。

在文件里写文件log,把当前的时间记录到log里,看是否执行了

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn