Cron Job (Task Scheduling) For Laravel Ubuntu

Cron Job (Task Scheduling) For Laravel Ubuntu

2020, Jul 14    
  1. 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

Cronjob 1

For registering the command, go to app/console/kernal.php and place the following code:

Cronjob 2

fter that, If you want run Cron Job on Ubuntu (Linux), you will do:

  1. CD to path of your laravel Project and run:

Cronjob 3

After that, you will run command:

crontab -e And you add as image:

Cronjob 4

OR:

          • cd /path-to-your-project && php artisan schedule:run » /dev/null 2>&1

Finish :D