Try to search your question here, if you can't find : Ask Any Question Now ?

Update Database using Laravel Schedule Cronjob

HomeCategory: stackoverflowUpdate Database using Laravel Schedule Cronjob
Avatarpushpa asked 2 weeks ago

I am trying to run an Eloquent model to insert data to the database, I tried to run a test run using Laravel schedule and cronjobs, below is my code

This is my AppConsolekernel.php

protected $commands = [
    'AppConsoleCommandstest',
];

/**
 * Define the application's command schedule.
 *
 * @param  IlluminateConsoleSchedulingSchedule  $schedule
 * @return void
 */
protected function schedule(Schedule $schedule)
{

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

}

And my AppConsoleCommandstest

protected $signature = 'check:test';
public function handle()
{

        try {
            $test = new Test([
                "user_id" => 1,
                "data_one"=>321,
            ]);
            $test->save();
            return response()->json('successfully added');

        } catch (exception $e) {
            return response()->json('error', $e);

        }

}

and my crontab -e code is,

* * * * * php /opt/lampp/htdocs/testProj/artisan schedule:run 1>> 
/opt/lampp/htdocs/testProj/schedule.log 2>&1

when excecuted the log I get is,

Running scheduled command: ‘/usr/bin/php7.2’ ‘artisan’ check:test > ‘/dev/null’ 2>&1

And there is no change in the database either.
What am i doing wrong, Any help would be appreciated

1 Answers
Best Answer
AvatarArben answered 2 weeks ago
Your Answer

3 + 10 =

Popular Tags

WP Facebook Auto Publish Powered By : XYZScripts.com