API hosting

Deploy a Flask cron job on DenkOps

Serverless cron triggers spin up a fresh function on every tick, so any in-memory state from the last run is gone. On DenkOps the schedule library runs inside your single long-lived Flask process, so a background loop can carry state, like a last-run timestamp or a retry counter, across every tick without touching disk. The more DenkOps-native option, especially for Python, is managed declarative cron: declare the schedule in denkops.json and DenkOps calls a route your Flask app already serves, no background thread or scheduler library needed, and every run is visible and manually triggerable from the dashboard's Scheduled jobs panel or the MCP list_crons and run_cron tools.

import time, threading, schedule
from flask import Flask

app = Flask(__name__)

def job():
    print("running nightly report")

schedule.every().day.at("02:00").do(job)

def run_scheduler():
    while True:
        schedule.run_pending()
        time.sleep(30)

threading.Thread(target=run_scheduler, daemon=True).start()

@app.get("/health")
def health():
    return {"ok": True}

# Alternative: DenkOps managed declarative cron, no background thread needed.
# denkops.json
# {
#   "cron": [
#     { "schedule": "0 2 * * *", "path": "/jobs/nightly", "method": "POST", "timezone": "UTC", "name": "nightly" }
#   ]
# }

@app.post("/jobs/nightly")
def nightly_job():
    print("running nightly report")
    return {"ok": True}

Deploy it: install the plugin, say "deploy on DenkOps", and get a live SSL URL.

Start on DenkOps →

FAQ

Can I run scheduled jobs on DenkOps without a separate cron service?

Yes. Because a slot runs continuously, a lightweight in-process scheduler like the schedule library replaces the need for an external cron trigger entirely.

What happens to my cron job's state between runs on DenkOps?

It stays in memory, the process never restarts between ticks, so counters, timestamps, and caches persist naturally, and you can back anything important with /persist.

Do I need the schedule library for cron jobs on DenkOps?

No, not necessarily. DenkOps also supports managed declarative cron: list a schedule and a path in denkops.json and DenkOps calls that route directly, no in-process scheduler needed, and the run is visible and manually triggerable from the dashboard's Scheduled jobs panel or the MCP list_crons and run_cron tools.

← Deploy AI agents · API hosting