Search code examples
croncpanellumen

how to setup cron job for Lumen Applicaiton in shared hosting (using CPanel)?


I have created one command which will add some record to mysql database.

When I execute command with terminal, command is adding data to database.

Then I have modified Kernel.php, added command in commands array and scheduled task as below.

protected $commands = [

           \App\Console\Commands\AddData::class,
   ]; 
 protected function schedule(Schedule $schedule)
    {
        $schedule->command('word:add')->everyMinute();      
    }

I have setup cron job in CPanel.

Command Setting : Once per minute.

Command added as :

/usr/local/bin/php /home/username/public_html/sitename/projectPath && php artisan schedule:run >> /dev/null 2>&1

But it is not working - i.e. not adding row to database table neither I am getting any error from in CPanel for cron job. am I missing anything or I am doing something wrong with it?


Solution

  • I have figure out the problem. for this case, we need to give path of artisan file, so the command would be

    * * * * * /usr/local/bin/php /home/username/public_html/sitename/projectPath/artisan schedule:run >> /dev/null 2>&1