I created a cron that should check every minute if the value of the end date is smaller than the current one ... if yes it should update the status field of this table.
class SetStatus extends Command
{
protected $signature = 'SetStatus:cron';
public function handle()
{
//o código ta uma zona apenas pra teste...
$sql = 'select id from promotions where dt_end < NOW()';
$dados = \DB::select($sql);
foreach($dados as $i)
{
$updateStatus = 'update promotions set status = "inativo" where id IN ('.$i->id.')';
$return = \DB::update($updateStatus);
}
var_dump($return);
}
}
and added in the kernel
protected $commands = [
Commands\SetStatus::class,
];
protected function schedule(Schedule $schedule)
{
$schedule->command('SetStatus:cron')->everyMinute();
}
My question is that every time I run the commands below, CRON runs successfully, but stops there. The next minute it does not run again.
php artisan SetStatus:cron
php c:/projetos/marcelo/painel/artisan schedule:run
After running these commands above, should not it be run every time I set it in the kernel?
I found something interesting in this link Schedule page load through CRON in line
# crontab -e 00 * * * * /usr/local/bin/php /home/pedrodelfino/meu-script.php
But I could not unroll ... I also saw something like creating a .bat, but I did not find it functional.
I'm in the development environment using Windows, could anyone give a light?