Step 1: Create command in laravel
php artisan make:command YourCommand
in /app/console/commands
YourCommand.php
Update line
protected $signature = 'yourcommand:cron';
Create your logic in function
public function handle()
{
// Your Code Here
}
in crontab linux command
sudo crontab -e
press INSERT Button
add command
* * * * * cd /var/www/html/yourproject/ && php artisan schedule:run >> /dev/null 2>&1
save:
type (:wq)
Add cronjob in Kernel.php
protected function schedule(Schedule $schedule)
{
$minutes = env("CRON_INTERVAL",15);
// $schedule->command('testcronjob:cron')
// ->cron($minutes.' * * * *');
$schedule->command('testcronjob:cron')
->cron('10 * * * *'); //cron('1 * * * *');
// $schedule->command('testcronjob_half_hour:cron')
// ->cron('30 * * * *'); //cron('1 * * * *');
// $schedule->command('testcronjob_quarter:cron')
// ->cron('45 * * * *'); //cron('1 * * * *');
// $schedule->command('testcronjob_hour:cron')
// ->cron('* 1 * * *'); //cron('1 * * * *');
// $schedule->command('testcronjob_hour_15:cron')
// ->cron('15 1 * * *'); //cron('1 * * * *');
// $schedule->command('testcronjob_hour_30:cron')
// ->cron('30 1 * * *'); //cron('1 * * * *');
// $schedule->call(function () {
// Log::info(': Job Run Successfully. ');
// })->cron(' * * * *');
}
php artisan make:command YourCommand
in /app/console/commands
YourCommand.php
Update line
protected $signature = 'yourcommand:cron';
Create your logic in function
public function handle()
{
// Your Code Here
}
in crontab linux command
sudo crontab -e
press INSERT Button
add command
* * * * * cd /var/www/html/yourproject/ && php artisan schedule:run >> /dev/null 2>&1
save:
type (:wq)
Add cronjob in Kernel.php
protected function schedule(Schedule $schedule)
{
$minutes = env("CRON_INTERVAL",15);
// $schedule->command('testcronjob:cron')
// ->cron($minutes.' * * * *');
$schedule->command('testcronjob:cron')
->cron('10 * * * *'); //cron('1 * * * *');
// $schedule->command('testcronjob_half_hour:cron')
// ->cron('30 * * * *'); //cron('1 * * * *');
// $schedule->command('testcronjob_quarter:cron')
// ->cron('45 * * * *'); //cron('1 * * * *');
// $schedule->command('testcronjob_hour:cron')
// ->cron('* 1 * * *'); //cron('1 * * * *');
// $schedule->command('testcronjob_hour_15:cron')
// ->cron('15 1 * * *'); //cron('1 * * * *');
// $schedule->command('testcronjob_hour_30:cron')
// ->cron('30 1 * * *'); //cron('1 * * * *');
// $schedule->call(function () {
// Log::info(': Job Run Successfully. ');
// })->cron(' * * * *');
}
No comments:
Post a Comment