2014-10-27 64 views
0

我迷失在我做错了,我看不到任何人有这个问题,所以它一定是我。调度员w/Laravel复制输出

我刚刚设置了Indatus\Dispatcher\ServiceProvider并且一切正常。出于测试目的,我只是每5分钟运行一个预定事件来添加日志条目。

出于某种原因,它正在复制日志条目。

下面是输出看起来像:

[2014-10-26 19:00:15] local.INFO: This is a test [] [] 
[2014-10-26 19:00:15] local.INFO: This is a test [] [] 
[2014-10-26 19:05:12] local.INFO: This is a test [] [] 
[2014-10-26 19:05:13] local.INFO: This is a test [] [] 
[2014-10-26 19:10:09] local.INFO: This is a test [] [] 
[2014-10-26 19:10:10] local.INFO: This is a test [] [] 

这里的实际安排fire()事件:

public function fire() 
{ 
    Log::info('This is a test'); 
} 

schedule()

public function schedule(Schedulable $scheduler) 
{ 
    return $scheduler->everyMinutes(5); 

} 

,我已经检查了scheduled:summary它只显示一次:

+----------------+------------------+-----------+--------+------+--------------+-------+-------------+--------+ 
| Environment(s) | Name    | Args/Opts | Minute | Hour | Day of Month | Month | Day of Week | Run as | 
+----------------+------------------+-----------+--------+------+--------------+-------+-------------+--------+ 
| *    | schedule:test |   | */5 | * | *   | *  | *   |  | 
+----------------+------------------+-----------+--------+------+--------------+-------+-------------+--------+ 

最后我的crontab条目,这是唯一的一次文件中列出:

* * * * * php /vagrant/myapp/artisan scheduled:run 1>> /dev/null 2>&1 

我看不到会导致它运行两次任何重复。

任何想法我错了什么?

**编辑:**

按照要求,从测试命令全文:

使用Indatus \调度\计划\ ScheduledCommand; 使用Indatus \ Dispatcher \ Scheduling \ Schedulable; 使用Indatus \ Dispatcher \ Drivers \ Cron \ Scheduler; 使用Symfony \ Component \ Console \ Input \ InputOption; 使用Symfony \ Component \ Console \ Input \ InputArgument;

class NewSchedule extends ScheduledCommand { 

    /** 
    * The console command name. 
    * 
    * @var string 
    */ 
    protected $name = 'schedule:test'; 

    /** 
    * The console command description. 
    * 
    * @var string 
    */ 
    protected $description = 'This is a test command'; 

    /** 
    * Create a new command instance. 
    * 
    * @return void 
    */ 
    public function __construct() 
    { 
     parent::__construct(); 
    } 

    /** 
    * When a command should run 
    * 
    * @param Scheduler $scheduler 
    * @return \Indatus\Dispatcher\Scheduling\Schedulable 
    */ 
    public function schedule(Schedulable $scheduler) 
    { 
     return $scheduler->everyMinutes(5); 
    } 

    /** 
    * Execute the console command. 
    * 
    * @return mixed 
    */ 
    public function fire() 
    { 
     Log::info('This is a test'); 
    } 


} 
+0

不应该是他们唯一的一个> – 2014-10-27 02:04:43

+1

Crondeamon可能运行两次 – 2014-10-27 02:12:47

+0

如果你运行'PHP工匠时间表:???在命令行test' - 它只有一个或两个enteries添加到日志 – Laurence 2014-10-27 04:06:11

回答

4

检查,以确保只有一个cron守护程序运行时,通过发出以下命令,从根:

ps aux | grep [c]ron 

...,并确保只有一个结果。如果还有更多,则多个进程正在运行并触发分派器。

您也可以确保不误添加调度crontab中为多个用户(包括vagrantroot,例如:

sudo ls /var/spool/cron/crontabs 

...查看哪些用户有活动crontabs有只应是一个结果

+0

'ps aux | grep [c] ron'只显示一个项目:'root 877 0.0 0.2 19104 1028? Ss 13:53 0:05 cron';检查crontab只有一个条目。 – TH1981 2014-10-31 20:48:40

+0

你可以发布你的'test'命令的完整代码吗?上面添加了 – damiani 2014-10-31 21:11:03

+0

。 ta – TH1981 2014-10-31 21:28:46