Search code examples
apache-nifi

How do I use parameters for cron expressions in Nifi processors


I would like to schedule processors using cron expressions defined in parameters that are passed as environment variables. However, regardless of how I define these environment variables, they end up with additional double quotes, resulting in errors. I've tried several approaches, e.g.:

  • set ALERT_MAIL_CRON=0\ 8\ *\ *\ *\ ?
  • set ALERT_MAIL_CRON=0 8 * * * ?
  • set ALERT_MAIL_CRON="0 8 * * * ?"

Nifi Version: 2.0.0-M1

OS: Windows 11

enter image description here

The error message:

Scheduling Period '#{ALERT_MAIL_CRON}' is not a valid cron expression: For input string: ""0" '"0' in cron expression ""0 8 * * * ?""

Solution

  • You both weren't wrong, but my issue was something else. The environment variables don't synchronize into Parameter Contexts automatically on startup. On first setup of those environment variable parameter provider, parameters will be fetched from environment variables.

    On every startup you need to upate them manually by pressing the fetch and apply button: enter image description here