How to start a cron job using schedule:run manually in Laravel 5 (October CMS actually) -


i know how run cron jobs on linux server, know how use $schedule->command('foo')->daily(); have read document many times https://laravel.com/docs/5.0/artisan

but question shall write line $schedule->command('foo')->daily();? , $schedule variable actually? mean predefined variable in parent classes can directly call if not class shall include in our file , how instantiate $schedule object.

my main concern elegant way schedule jobs, point of writing in code writing logic because line should run once in lifetime if not wrong because push job in jobs table , * * * * * php /path/to/artisan schedule:run 1>> /dev/null 2>&1 should take care of rest of lifetime

then shall write such code run once while deploying application on server before starting main cron schedule:run.

please, guide me why there no written document how run scheduled task manually without writing in code called many time during execution of real world web application.

first, unless you're using laravel 5.0, specifically, you'll want make sure you're looking @ right version documentation (and if using 5.0, specifically, highly recommend upgrading, it's long out of support). current version (as of writing) is 5.5, , october cms has been updated accordingly.

as question, if i'm understanding right, don't want scheduled, repeating job, an artisan command. write artisan command, create class in console/commands folder (this can generated make:command artisan command) , register in console/kernel.php. can access running php artisan your:command (where your:command name you've chosen command).

if want schedule repeating job, put $schedule line console/kernel.php. $schedule variable imported through laravel's dependency resolver.

if have deployment script use, , want call single command programmatically, can with artisan::call(), within deploy script (be sure import artisan facade):

artisan::call('your:command'); 

Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -