Issue
I tried this for days and seeking answers but it still not working
* * * * * usr/bin/php /home/dss/laravelAppDss/artisan schedule:run >> /dev/null 2>&1
Here is my Kernel.php
<?php
namespace App\Console;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
class Kernel extends ConsoleKernel
{
protected $commands = [
'\App\Console\Commands\SinkronDSS',
];
protected function schedule(Schedule $schedule)
{
$schedule->command('sinkron:dss')->daily()->timezone('Asia/Singapore');
}
protected function commands()
{
require base_path('routes/console.php');
}
}
Here is my SinkronDSS.php
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
class SinkronDSS extends Command
{
protected $signature = 'sinkron:dss';
protected $description = 'Sinkron DSS';
public function __construct()
{
parent::__construct();
}
public function handle()
{
$sync = app('\App\Http\Controllers\SinkronisasiC')->db_pdd(true);
$sync = app('\App\Http\Controllers\SinkronisasiC')->db_pdm(true);
$sync = app('\App\Http\Controllers\SinkronisasiC')->db_pdp(true);
$sync = app('\App\Http\Controllers\SinkronisasiC')->db_remun(true);
$sync = app('\App\Http\Controllers\SinkronisasiC')->db_kinerja(true);
}
}
I tried php artisan schedule:run in local and it's working fine...
Anyone know where is the problem?
Solution
Sorry that I do not have enough reputations to leave comment so I need to write as an answer....
If you can run php artisan schedule:run
, I would suggest it seems that the cronjob is not running with the correct path to php
.
Have you tried
usr/bin/php /home/dss/laravelAppDss/artisan schedule:run
?Have you tried to add
/
beforeuser/bin/php
? i.e.:* * * * * /usr/bin/php /home/dss/laravelAppDss/artisan schedule:run >> /dev/null 2>&1
Answered By - label Answer Checked By - David Marino (WPSolving Volunteer)