Search code examples
phplaravel-5bitnami

Laravel schedule:run command is not working


I am setting background schedule in laravel on live server (Linux). I am using bitnami. But schedule:run is not working when i am using comand like this:

* * * * * /opt/bitnami/php/bin/php /opt/bitnami/apache2/htdocs/turnfitter/artisan schedule:run 1>> /dev/null 2>&1

I also tried like this:

* * * * * php artisan schedule:run 1>> /dev/null 2>&1 ###

No error occurs but schedule is not working.

When i am trying like that:

php artisan schedule:run 1>> /dev/null 2>&1

or like

/opt/bitnami/php/bin/php /opt/bitnami/apache2/htdocs/turnfitter/artisan schedule:run 1>> /dev/null 2>&1

without asterisk (*) then it works but only one command processed which I set to every minute in my schedule in kernel like this:

$schedule->command('payment:check')->everyMinute();

But it only run once when I run schedule:run command after that do nothing. Other commands I am calling hourly, daily etc. are not working at all.

Please can any one tell what could be the problem?


Solution

  • Using the Bitnami LAMP Stack available at https://bitnami.com/stack/lamp

    These are the steps I followed to successfully set the Schedule on Laravel:

    • Uncomment the line below on the Apache congirutation file /opt/bitnami/apache2/conf/bitnami/bitnami-apps-prefix.conf:

      #Include "/opt/bitnami/lampstack-5.6.26-3/frameworks/laravel/conf/httpd-prefix.conf"
      
    • Edit the method schedule on the file /opt/bitnami/frameworks/laravel/app/Console/Kernel.php:

      protected function schedule(Schedule $schedule)
      {
          $schedule->exec('echo "Hello World"')
            ->everyMinute()
            ->appendOutputTo('/tmp/laravel.log');
      }
      
    • Restart Apache: sudo /opt/bitnami/ctlscript.sh restart apache

    • Run: /opt/bitnami/php/bin/php /opt/bitnami/frameworks/laravel/artisan schedule:run >> /dev/null 2>&1

    Results:

    • The Laravel Sample project was available at: http://127.0.0.1/laravel/
    • Every minute a "Hello world!" line was added on /tmp/laravel.log

    You should visit: