DEV Community

Cover image for Cron Is Great... Until Your Business Gets Involved
The Unmeshed Team
The Unmeshed Team

Posted on • Originally published at unmeshed.io

Cron Is Great... Until Your Business Gets Involved

Introduction

Workflow automation is a critical component of many business operations, handling tasks that require minimal human involvement. From generating financial reports and running overnight data jobs to performing system checks during maintenance windows, automation ensures these processes run efficiently and reliably.

These processes often rely on recurring execution, traditionally handled with cron expressions. While cron is effective for fixed intervals, it quickly becomes limiting when workflows need to align with real-world business calendars.

Unmeshed already offers robust cron-based scheduling for repeatable jobs, such as every hour or every day at 5 AM. But for more complex real-world scenarios, we introduced Calendar Scheduling. This feature lets you define custom calendars that act as intelligent filters, ensuring workflows run only on specific and valid days. You can also combine calendars, dynamically generate schedules, and control how jobs respond to skipped or excluded dates.

Supported Calendar Types in Unmeshed

Unmeshed supports four calendar types, each built for different scheduling needs:

  • List of Dates Calendar
  • Code Calendar
  • Derived Calendar
  • Reschedule Calendar

1. List of Dates Calendar

The List of Dates Calendar allows users to manually select execution dates through the UI.

Features

  • Define a date range and select individual days using a visual calendar.
  • Quickly select common patterns such as:
    • Weekends
    • Weekdays
    • Specific weekdays (for example, every Monday)
  • Switch between Calendar View and List View to manage selected dates.

Use Cases

  • Non-technical users who prefer visual scheduling.
  • Fixed schedules such as monthly reviews or quarterly tasks.

2. Code Calendar

The Code Calendar enables developers to generate execution dates programmatically.

Code Calendar in Unmeshed showing a JavaScript editor for defining custom scheduling logic and generating workflow execution dates programmatically.

Features

  • Write custom logic to generate valid execution dates.
  • Use built-in templates to get started quickly.
  • Ideal for advanced scheduling scenarios such as:
    • Every third Friday of the month
    • First working day after a public holiday

Use Cases

  • Logic-driven scheduling.
  • Business rules that depend on application data.

3. Derived Calendar

The Derived Calendar combines two existing calendars using set operations.

Derived Calendar in Unmeshed showing calendar operations such as Union, Intersection, Difference, and Symmetric Difference to generate execution schedules from existing calendars.

Supported Operations

  • UNION — Combines all dates from both calendars.
  • INTERSECTION — Includes only dates present in both calendars.
  • DIFFERENCE — Includes dates from the source calendar that are not in the target calendar.
  • SYMMETRIC DIFFERENCE — Includes dates unique to either calendar.

Key Notes

  • Derived calendars cannot be edited manually.
  • Dates are automatically computed from the selected calendars and operation.
  • Preview the generated schedule before saving.

Use Cases

  • Combining multiple scheduling rules.
  • Excluding holidays from business-day calendars.

4. Reschedule Calendar

The Reschedule Calendar handles situations where scheduled executions need to be postponed instead of skipped.

Reschedule Calendar in Unmeshed showing skipped execution dates, configurable reschedule delays, and calendar-based exception handling for workflow scheduling.

Features

  • Skip execution on selected dates, such as holidays or maintenance windows.
  • Automatically reschedule skipped jobs after a configurable delay.
  • Fine-grained control over exception handling.

Use Cases

  • Holiday scheduling.
  • Planned maintenance windows.
  • Blackout periods.
  • Postponing jobs without cancelling them.

Using Calendars in the Job Scheduler

Calendars can be attached to schedules to control when jobs are allowed to run.

Each schedule can define either:

  • A CRON expression, or
  • A fixed execution time (for example, 9:00 AM)

When a calendar is associated with a schedule:

  • The calendar acts as a filter for eligible execution dates.
  • Jobs run only on dates included in the calendar at the configured time.

Note: Every calendar includes a preview of future execution dates, making it easy to validate schedules before deployment and avoid unexpected behavior.


Final Thoughts

Calendar Scheduling gives you fine-grained control over workflow execution by letting calendars filter your schedules.

Instead of forcing business rules into increasingly complex cron expressions, you can define calendars that reflect how your business actually operates.

If your workflows depend on holidays, business days, maintenance windows, or custom scheduling rules, calendar-based scheduling provides a much cleaner and more maintainable solution.

Top comments (0)