This application relates to the field of task scheduling technology and discloses a task scheduling method and
system based on cross-day switching and jump compensation using dual time wheels. First, scheduled tasks are acquired and stored in a global task table according to their planned execution dates, then attached to the corresponding slots of today's or tomorrow's time wheel. A
heartbeat-based
cyclic scheduling is initiated at a preset period. In each
heartbeat, the
calendar date is checked for changes; if a change occurs, residual tasks for expired calendar dates are discarded, and today's and tomorrow's time wheels are swapped. The
system time difference between two adjacent heartbeats is calculated to determine the currently observed slot. If there are any unexecuted expired tasks, tasks within the corresponding interval are executed; if the slot mapping fails, tasks are reassigned to the corresponding slots. Expired tasks in the current slot are executed and removed from the wheel, and this process is repeated until the global task table is cleared. This application achieves constant-time slot placement and switching for cross-calendar-day tasks, avoiding batch miscontrols at
midnight, and automatically compensating for missed tasks after
system time jumps.