Hello! When we work on a Laravel project, automated tasks will always come up, and what better than to use Laravel's Task Scheduling, where we customize when and what command will be executed, whether they are Laravel commands as such or custom commands, everything works fine locally (in my case I didn't test the cron since I use Windows) until the day comes when we upload it to our server and add the main cron to our system:
* * * * * php /path/to/artisan schedule:run >> /dev/null 2>&1
But when testing a command, which for example, must be executed daily at 00:01 as would be the case of a birthday email to our users:
$schedule->command('email:birthday')->dailyAt('00:01')->withoutOverlapping();
It just so happens that at the indicated time nothing happens, the email is not sent at the indicated time and if we do a:
sudo grep CRON /var/log/syslog
We see that our main command artisan schedule:run >> /dev/null 2>&1 is running minute by minute, but the email does not appear.
In my case the problem was that in my configuration file config/app.php
I had NOT specified the correct Timezone, it was in UTC, and not the one corresponding to my server, which should be 'America/Santiago' in my case, to finish, the line in app.php would be in my case:
'timezone' => 'America/Santiago',
And finally!!, once I changed the time of my task to a minute close to the current one (so as not to wait 24 hours xD!) the birthday email appeared
I hope it helps more than one person.
Page loaded in 24.87 ms