skip to Main Content

I have the following method in my Kernel.php (the one under Console of course):

protected function schedule(Schedule $schedule)
{
    $schedule->exec("touch lorem.txt")->everyMinute();
}

And I have the following cronjob added through the cpanel:

* * * * * cd /home/oeit/oe && php artisan schedule:run >> /dev/null 2>&1

I am supposed to see a lorem.txt file in the disk. However when I search for it using find / -name "lorem.txt" the file doesn’t appear, which makes me believe that my cronjob is not working properly. I am on a shared hosting.

How do I fix this?

2

Answers


  1. Chosen as BEST ANSWER

    I had to specify the full path for the php executable:

    * * * * * cd /home/oeit/oe && /usr/local/bin/php artisan schedule:run >> /dev/null 2>&1
    

  2. If you’re on shared hosting, it’s entirely possible that it is running, but you don’t have access to use $schedule->exec on the server.

    I would take a look in the storage/logs/laravel.log file to see if you are getting any errors.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search