laravel scheduling run one time

Published 9 months ago by thesogafoi

Hey Guys i used Scheduling in laravel and do something like this in kernal

$schedule->command('mail:daily')->everyMinute();

and i created mail:daily command and when i run schedule :

php artisan schedule:run
Running scheduled command: '/usr/bin/php7.2' 'artisan' mail:daily > '/dev/null' 2>&1

it done and email sent but a problem i have ,

it send me email for one time, it is Not run mail:daily over and over in every minute why So what can i do

Best Answer (As Selected By thesogafoi)
Snapey

Yes, you need to be on a platform that supports crontab and have ssh access.

Many shared hosts don't support this, so I wrote this article several years ago http://novate.co.uk/help-my-host-does-not-support-cron-jobs/

Snapey
Snapey
9 months ago (1,036,815 XP)

You need a cron job that runs the schedule:run command per minute. Your schedule command will then check if it is time to run.

thesogafoi

How Can i do this ? @snapey

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

with this ?

Snapey
Snapey
9 months ago (1,036,815 XP)

Yes, you need to be on a platform that supports crontab and have ssh access.

Many shared hosts don't support this, so I wrote this article several years ago http://novate.co.uk/help-my-host-does-not-support-cron-jobs/

thesogafoi

@snapey thx man

  1. can i do scheduling in local host Or not ?
  2. if we should cron Job then what is this methods :
 everyMinute

then this functions donot nothing for us

Snapey
Snapey
9 months ago (1,036,815 XP)

Sorry I don't understand your question. You can schedule in local host but it depends if cron is supported.

You run the scheduler every minute (that is what * * * * * means) and then in the scheduler say everyDay, everyHour, everyMonday etc

thesogafoi

@snapey

I get it

in your article you run schedule in online Host but in local how can i do this ?

i use Homestead On windows

Snapey
Snapey
9 months ago (1,036,815 XP)

You should be able to run cron in homestead.

thesogafoi

But How Can i do this @snapey

Snapey
Snapey
9 months ago (1,036,815 XP)

Sorry, I've never used homestead, but it is covered in the docs https://laravel.com/docs/5.5/homestead#configuring-cron-schedules

thesogafoi

Thank you A lot @Snapey

Please sign in or create an account to participate in this conversation.