Velvet Star Monitor

Standout celebrity highlights with iconic style.

updates

How can I test my cron job in localhost windows? (laravel 5.3)

Writer Matthew Barrera

I create a cron job on laravel 5.3 by editing app\Console\Kernel.php like this :

<?php
namespace App\Console;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
use DB;
class Kernel extends ConsoleKernel
{ protected $commands = [ // ]; protected function schedule(Schedule $schedule) { $schedule->call(function () { $id = 1; DB::table('orders') ->where('id', $id) ->update(['status ' => 2, 'canceled_at' => date("Y-m-d H:i:s")]); })->everyMinute(); } protected function commands() { require base_path('routes/console.php'); }
}

I tried to check on the table in the database, but it does not update

How can I test my cron job?

3 Answers

You can follow below steps:

1) You can run php artisan list command in cmd and find your cron.

2) After find your cron, then you can run php artisan yourcron.

You can follow this link for more details about cron job.

Hope this work for you!

2

Go to the project directory and run

php /path/to/artisan schedule:run

More info about that:

hey you can create log file too at the time of defining cron. as i ahve created mine...

* * * * * php /var/www/html/sharep/artisan ElasticSearch:ElasticSearchData >> /var/www/html/sharep.log 2>&1

this cron run after 1 minute. and the logs saves in .log file as mention above.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy