murilo's avatar
Level 10

Cron Tab / Nginx + Ubuntu + Laravel

Hello I have been trying to make the cron Job in a Ubuntu / Nginx Server , in digital Ocean . I have tried , many options -

* * * * * php /var/www/laravel/artisan schedule:run 1>> /dev/null 2>&1
* * * * * /usr/bin/php /var/www/laravel/artisan schedule:run 1>> /dev/null 2>&1
* * * * * /usr/bin/php /var/www/laravel/artisan schedule:run > /dev/null >> /dev/null 2>&1

But I was no success, I dont know what I am doing wrong .

0 likes
4 replies
Snapey's avatar
Snapey
Best Answer
Level 122

The one in the Laravel docs should work;

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

but I use

* * * * * /usr/bin/php /var/www/html/sitename/Live/artisan schedule:run >> /dev/null 2>&1

I also run the cron job under the user account of the web server so that there is no argument about who owns any created files (such as log files). If your cron job runs as root and it creates the logfile (for instance) then the webserver will never be able to write to the log

1 like
chaudigv's avatar

Can you share your console\kernel.php just to make sure that you have scheduled commands the right way.

1 like
murilo's avatar
Level 10

It is working , sorry . it was my mistake .

Please or to participate in this conversation.