Heim  >  Artikel  >  Backend-Entwicklung  >  linux crontab 定时运行php文件

linux crontab 定时运行php文件

WBOY
WBOYOriginal
2016-06-23 14:03:281405Durchsuche

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里,看是否执行了

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn