简体   繁体   English

cron同时运行php脚本

[英]cron to run php script simultaneously

I've set 3 crons to execute php files at every day at midnight. 我设置了3克朗来每天午夜执行php文件。 Every script does its own job like say a.php, b.php and c.php 每个脚本都有自己的工作,例如说a.php,b.php和c.php

a.php -> picks the term(text) from database and search it in google, facebook, twitter, google+ and store the results in database. a.php->从数据库中选择术语(文本),然后在google,facebook,twitter,google +中进行搜索并将结果存储在数据库中。

b.php -> picks the image from our website and search it in tineye.com database and store the results b.php->从我们的网站中选择图像,然后在tineye.com数据库中进行搜索并存储结果

c.php -> picks the business name and search its reviews on citygrid.com, google places, yelp.com and store them in database. c.php->选择公司名称,并在citygrid.com,google地方,yelp.com上搜索其评论,并将其存储在数据库中。

After every fetch it updates the next execution date, so that it could fetch the data for that term/image/business on that date. 每次获取后,它都会更新下一个执行日期,以便可以在该日期获取该期限/图片/业务的数据。

My problem is 我的问题是

One, I've seen only few records from database are fetched and updated to db and later records are not updated. 第一,我只看到很少的数据库记录被提取并更新到db,以后的记录也没有更新。 This could be because while fetching the data for starting terms, execution time get expired and it doesn't continue. 这可能是因为在获取起始条款的数据时,执行时间已到期并且不会继续。 I tried increasing the max_execution_time to 100000 but no luck. 我尝试将max_execution_time增加到100000,但是没有运气。

Two, I see a.php, b.php and c.php doesn't start at same time. 二,我看到a.php,b.php和c.php不在同一时间启动。

syntax I used: 我使用的语法:

0 0 * * * /usr/bin/php /var/www/html/a.php
0 0 * * * /usr/bin/php /var/www/html/b.php
0 0 * * * /usr/bin/php /var/www/html/c.php

I need the advice from the genius to make it work best. 我需要天才的建议才能使其发挥最佳效果。

When you run PHP from the command line (/usr/bin/php) there is no max_execution time. 当您从命令行(/ usr / bin / php)运行PHP时,没有max_execution时间。 The max_execution is only used when using PHP from a webserver. 仅当从Web服务器使用PHP时才使用max_execution。

Try debugging the output when running the scripts by hand, setting error_reporting to E_ALL and output a lot of debug information. 手动运行脚本时,尝试调试输出,将error_reporting设置为E_ALL并输出许多调试信息。 I think there is something wrong with your script that allows it to die without a message or something like that. 我认为您的脚本有问题,使它可以在没有消息或类似信息的情况下消失。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM