3

I've a Laravel 5.2 application, I'm using the scheduler to runs a script every 30 minutes by now. But I'm wondering if that time can be retrieved from the database, I want that the admin user configure that time from the webpage, I have the field in the database. But I'm not really sure if the scheduler can update that time from the database, so, is it possible?

Also, I setted: ->sendOutputTo("/var/www/html/laravelProject/public/output")

to save the output in a file named output, but it's not seems that is working even when the cron is executed, I checked the cron log files and there only shows that there is not MTA installed, but I don't want for the moments to send a e-mail, I just want to save the output in a file, so, what am I missing there?

Sredny M Casanova
  • 4,735
  • 21
  • 70
  • 115

1 Answers1

2

You can use when The when method may be used to limit the execution of a task based on the result of a given truth test.

 $schedule->command('yourcommand:execute')->everyMinutes()->when(function () {
        if($timefromdb){
            return true;
        }
        else{
            return false;
         }

    });

https://laravel.com/docs/master/scheduling#schedule-frequency-options

sumit
  • 15,003
  • 12
  • 69
  • 110
  • umm but, in this case I have to control the time. In the database I only want to save: every "30 minutes", "1 hour"...etc. With `when` I have to save the last execution time and then compare, and I want another way to achieve it – Sredny M Casanova Feb 20 '17 at 15:42