I would like to know how to schedule a cron job to run daily at 00:01.
I created a JOB in the App/Jobs folder
<?php namespace App\Jobs; use App\Models\Result; use App\Jobs\Job; use Illuminate\Contracts\Bus\SelfHandling; use DB; set_time_limit(0); class UpdateActive extends Job implements SelfHandling { public static function ActiveUpdate() { Result::update(['draw_id' => 1, 'isactive' => 0 ]); } public static function downGrade() { try { UserRole::update(['permission' => 1, 'isactive' => 2 ]); } catch (QueryException $e ) {
in application / console / Kernel.php I added this link to the schedule method
protected function schedule(Schedule $schedule) { $schedule->call(function () { $check_draw = \App\Jobs\UpdateActive::ActiveUpdate(); })->everyMinute(); }
Please note that I used everyMinute for testing
In crontab -e I added
* * * * * php /home/vagrant/Code/projects/artisan schedule:run 1>> /dev/null 2>&1
but the graph does not seem to work, I think, because when I check the results table, the isactive field isactive not changed.
I wonder where I am going wrong, please. If someone did it in L5. What am I missing?
Baako source share