Cron Job (Task Scheduling) For Laravel Ubuntu
2020, Jul 14
- Create command
php artisan make:command NameCommand
One command will create at app/Console/Commands You can rename:
- protected $signature = ‘command:name’; example => protected $signature = ‘hour:update’;
- protected $description = ‘Command description’; example => protected $description = ‘Send an hourly email to all the users’;
You will change code in handle() function you want to execute
For registering the command, go to app/console/kernal.php and place the following code:
fter that, If you want run Cron Job on Ubuntu (Linux), you will do:
- CD to path of your laravel Project and run:
After that, you will run command:
crontab -e And you add as image:
OR:
- cd /path-to-your-project && php artisan schedule:run » /dev/null 2>&1
Finish :D