3
I created a cron that should check every minute that the value of the end date is less than the current one... if yes 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 to the kernel
protected $commands = [
Commands\SetStatus::class,
];
protected function schedule(Schedule $schedule)
{
$schedule->command('SetStatus:cron')->everyMinute();
}
My doubt is that whenever I run the commands below the 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, it should no longer be run every minute equal set in the kernel?
I found something interesting in this link Schedule page loading through CRON on the line
# crontab -e 00 * * * * /usr/local/bin/php /home/pedrodelfino/meu-script.php
But I couldn’t unroll... I also saw something like creating a . bat, but I didn’t find it functional.
I am in development environment using Windows, someone could give a light?
Thanks friend, that’s exactly it. The only bad side is that every time you open the php prompt and you undo what you’re doing at the moment kkk+ it helped me a lot. Mt thank you!
– hisoka
@Hisoka if I’m not mistaken so it doesn’t happen to have to select the "run when user is logged in or not"
– gmsantos