SimonAngatia's avatar

How do I start cron job on the server?

I have set up a cron job that calls a method on the controller every five minutes. However, it is not running. So I thought maybe there is a way of kicking off cron jobs after setting up application on the server. Any help?

$schedule->call('App\Http\Controllers\ProController@process')->everyFiveMinutes();
0 likes
10 replies
laracoft's avatar
laracoft
Best Answer
Level 27

@simonangatia

have you set up a cron entry in /etc/crontab?

* * * * *   root cd /var/www/project; php artisan schedule:run > /dev/null
1 like
laracoft's avatar

@simonangatia

yea so /etc/crontab is the kick off you are looking for, it will run every minute 24/7 after which, your $schedule->... will execute ProController@process every 5 minutes.

SimonAngatia's avatar

How can I do that if I am using c-panel, please? Centos 7

laracoft's avatar

@simonangatia

There is Cron jobs under Advanced in cPanel.

Basically the same thing, just make sure it is all * for every minute 24/7:

Snapey's avatar

yes, just run the schedule, but don't try using it to hit a controller.A lot won't work properly.

Its better to write a command that does whatever you need to do.

Please or to participate in this conversation.