Closed jamminjames closed 5 years ago
is $strcron outside your closure? if it this you have to ineject it inside to use it properly
$schedule = new Scheduler();
$schedule->php('filetorun.php')
->at("10 10 10 * *");
->when(function() use (strcron) {
if ($strcron) { return true; }
});
->output(['logs/cron_renewalemail.log'])
->run();
@jamminjames I think @rafaelmb got a point here, if you want to use a external variable in a Closure you have to specify it like the below
->when(function() use ($myExternalVariable) {
# ....
})
I have to be honest I haven't tried your code yet but the when
method works so there is no reason why in you code it shouldn't. Can you try the suggested solution and see if that works for you now?
thanks @rafaelmb!
Yes, that works, thank you!
I have a php script I want to run once a month or every day, depending on the value of certain values in a database.
I have no problem getting the variables into scheduler.php, but can't seem to write a function that will accomplish the above.
I've tried various ways of using the function lines you present, but can't get the result I need. What is the best way to do this?
It's not clear from the instructions if I should chain the command all into one thing, but maybe that's the key, like this, which I've seen in another cron scheduler:
Thank you!