How to configure Laravel cron jobs on Cpanel

Author
By Darío Rivera
Posted On in cPanel

Configuring Laravel cron jobs in Cpanel is a fairly simple task. In this post you will see how to perform such configuration and lose the fear of scheduled system tasks, which Laravel already makes quite simple by itself.

The first step is to log in to your cpanel account via SSH. If you don't know how to do this yet, I invite you to check out our post Logging in to your Cpanel Account via SSH. Once there, you must verify that you have the proper access to execute the schedule:run command from Laravel.

[user@server]$ php artisan schedule:run
No scheduled commands are ready to run.

If everything has gone well, that is, you can run the command without problems, we can verify where the php binary comes from as follows:

[user@server]$ whereis php
php: /usr/bin/php /usr/lib64/php /usr/local/bin/php

That is, we can run the complete command like this

/usr/local/bin/php artisan schedule:run

Another thing you must have at hand is the directory where the artisan file is located. In my case:

/home/cpanel-user/laravel-app/artisan

Finally, we must log in to our cpanel account, look for the cron jobs option and create an entry that runs every minute like this:

icon widget

The command you must enter based on what we have obtained previously would be the following:

/usr/local/bin/php /home/cpanel-user/laravel-app/artisan schedule:run >> /dev/null 2>&1

Until next time!


Acerca de Darío Rivera

Author

Application Architect at Elentra Corp . Quality developer and passionate learner with 10+ years of experience in web technologies. Creator of EasyHttp , an standard way to consume HTTP Clients.

LinkedIn Twitter Instagram

Sólo aquellos que han alcanzado el éxito saben que siempre estuvo a un paso del momento en que pensaron renunciar.