【程序目录】优化定时任务

This commit is contained in:
wuhaotian 2025-06-19 14:38:09 +08:00
parent 71ba6730b8
commit 4e26c419fc

View File

@ -245,6 +245,11 @@ class SystemCrontabServices extends BaseServices
$crontabRunServices = app()->make(CrontabRunServices::class);
// 创建一个每秒钟执行一次的定时任务
new Crontab('*/1 * * * * *', function () use ($task, $crontabRunServices) {
// 写入时间戳,用于检测定时任务是否正常执行
$timerTime = file_get_contents(root_path() . 'runtime/.timer');
if ($timerTime < (time() - 60)) {
file_put_contents(root_path() . 'runtime/.timer', time());
}
// 从缓存中获取定时任务列表
$list = Cache::get('crontabCache');
if (!$list) {