You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Apache NiFi CRON表达式配置问题:非工作时段执行异常

Fixing Your NiFi CRON Schedule: Stopping Exactly at 07:00

Hey there, let's figure out why your processor is still running at 07:30 when you wanted it to stop at 07:00—your hunch about interval inclusivity is spot-on, but let's break down the specifics of how NiFi (which uses Quartz CRON under the hood) interprets these schedules.

The Root Cause: CRON Interval Logic

First, let's clarify how Quartz CRON handles hour ranges when the start value is higher than the end value (like 18-7). When you write * * 18-7 * * ?, NiFi/Quartz parses this as:

Run every second when the hour is 18 through 23, OR 0 through 7

That means your processor will keep triggering every second from 07:00:00 all the way to 07:59:59—explaining why you saw it running at 07:30. The interval includes the end value (7) in this case, which isn't what you want.

The Correct CRON Expression

To make the processor stop exactly at 07:00, you need to exclude the 7th hour entirely. Use this expression instead:

* * 18-23,0-6 * * ?

Let's break this down:

  • *: Every second
  • *: Every minute
  • 18-23,0-6: Hours 18 (6 PM) through 23 (11 PM), AND 0 (midnight) through 6 (6:59 AM)
  • *: Every day of the month
  • *: Every month
  • ?: Ignore day-of-week (since we're already specifying day-of-month)

This ensures the last trigger happens at 06:59:59, and no triggers fire starting at 07:00:00.

Quick Checks to Confirm

  1. Use NiFi's CRON Preview: When editing your processor's scheduling, click the small preview icon next to the CRON field. This will show you the next 10 trigger times—verify that none fall after 06:59:59.
  2. Verify Timezone: Make sure your NiFi instance and the processor's scheduling timezone match your intended local time. A timezone mismatch could make the stop time appear off.
  3. Check Scheduling Strategy: Ensure the processor is set to CRON Driven (not Timer Driven) in the scheduling settings—Timer Driven uses fixed intervals and might not respect CRON boundaries as strictly.

内容的提问来源于stack exchange,提问作者Stellar Sword

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 09:27:16