Skip to main content

Scheduled Tasks

While Rules are excellent for reacting instantly to events (like a new post), Scheduled Tasks allow you to run periodic sweeps or health checks across your subreddit based on a chronological schedule.

How Schedulers Work

Modegator utilizes the native Reddit Devvit Scheduler. A scheduled task executes a predefined Macro or Action array at regular intervals.

Configuration Structure

A Scheduled Task is defined in the scheduled array. It requires a name, a cron expression, and the action(s) to execute (such as run_macro).

scheduled:
- name: "Daily Health Check"
cron: "0 0 * * *"
run_macro: "Daily Report Macro"

macros:
- name: "Daily Report Macro"
actions:
- type: "send_modmail"
subject: "Daily Check"
body: "The subreddit is healthy."

Cron Expressions

Modegator supports standard 5-part Cron syntax. Note that the minimum resolution allowed by the Reddit platform is typically 1 minute.

Examples:

  • 0 * * * *: Run at the start of every hour.
  • */15 * * * *: Run every 15 minutes.
  • 0 0 * * *: Run at midnight every day.
  • 0 12 * * 1: Run at noon every Monday.

Context Limitations

It is critical to understand the execution context of a Scheduled Task. Unlike a Rule triggered by PostSubmit, a Scheduled Task runs in a Subreddit Context. It is not bound to a specific post or comment.

Therefore, the actions executed by a Scheduled Task cannot simply contain a remove_post action (because Modegator wouldn't know what to remove).

Instead, Scheduled Tasks are typically paired with specialized background actions like store_value, tag_domain, or sending reports via send_modmail.