Skip to content

Commit

Permalink
add run now
Browse files Browse the repository at this point in the history
  • Loading branch information
Mips2648 committed Jan 19, 2022
1 parent e321e60 commit 242a360
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/MipsEqLogicTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,14 @@ private static function executeAsync(string $_method, $_option = null, $_date =
$cron->setOption($_option);
}
$cron->setOnce(1);
$cron->setSchedule(cron::convertDateToCron(strtotime($_date)));
$scheduleTime = strtotime($_date);
$cron->setSchedule(cron::convertDateToCron($scheduleTime));
$cron->save();
log::add(__CLASS__, 'debug', "Task '{$_method}' scheduled at {$_date}");
if ($scheduleTime <= strtotime('now')) {
$cron->run();
log::add(__CLASS__, 'debug', "Task '{$_method}' executed now");
} else {
log::add(__CLASS__, 'debug', "Task '{$_method}' scheduled at {$_date}");
}
}
}

0 comments on commit 242a360

Please sign in to comment.