I'm lost on what I'm doing wrong, and I can't see anyone else with this problem, so it's gotta be me.
I've just setup Indatus\Dispatcher\ServiceProvider
and have everything running just fine. For testing purposes, I'm just running a single scheduled event every 5 minutes to add a log entry.
For some reason, it's duplicating the log entries.
Here's what the output is looking like:
[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 [] []
Here's the actual scheduled fire()
event:
public function fire()
{
Log::info('This is a test');
}
The schedule()
:
public function schedule(Schedulable $scheduler)
{
return $scheduler->everyMinutes(5);
}
and I've checked the scheduled:summary
and it's only showing once:
+----------------+------------------+-----------+--------+------+--------------+-------+-------------+--------+
| Environment(s) | Name | Args/Opts | Minute | Hour | Day of Month | Month | Day of Week | Run as |
+----------------+------------------+-----------+--------+------+--------------+-------+-------------+--------+
| * | schedule:test | | */5 | * | * | * | * | |
+----------------+------------------+-----------+--------+------+--------------+-------+-------------+--------+
And finally my crontab entry, which is only listed in the file once:
* * * * * php /vagrant/myapp/artisan scheduled:run 1>> /dev/null 2>&1
I can't see any duplication that would cause it to run twice.
Any ideas what I've got wrong?
**Edit: **
As requested, full text from the test command:
use Indatus\Dispatcher\Scheduling\ScheduledCommand; use Indatus\Dispatcher\Scheduling\Schedulable; use Indatus\Dispatcher\Drivers\Cron\Scheduler; use Symfony\Component\Console\Input\InputOption; use 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');
}
}
Check to make sure that only one cron daemon is running, by issuing this command, from root:
ps aux | grep [c]ron
...and make sure there is only one result. If there are more, then multiple processes are running and triggering Dispatcher.
You can also make sure the Dispatcher crontab wasn't mistakenly added for multiple users (both vagrant
and root
, for example:
sudo ls /var/spool/cron/crontabs
...to see what users have active crontabs
. There should only be one result.