Scheduled Jobs & Cron

Deploy background jobs that run on a cron schedule. Your code executes on schedule, scales to zero between runs, and you pay only for execution time.

How It Works

When you deploy with --schedule, Telbase creates a GCP Cloud Run Job (your code) and a Cloud Scheduler trigger (the cron). On each scheduled tick, Cloud Scheduler runs your job. When it finishes, the container shuts down — no idle compute.

bash
telbase deploy --schedule "0 * * * *"
Paid plans only
Scheduled jobs require a paid plan. Starter includes 1 slot (5 min timeout), Builder includes 3 slots (10 min), and Pro includes 10 slots (30 min). See pricing below.

Deploying a Scheduled Job

bash
# Deploy a job that runs every hour
telbase deploy --schedule "0 * * * *"

# Weekdays at 9 AM Eastern
telbase deploy --schedule "0 9 * * 1-5" --schedule-timezone "America/New_York"

# Every 15 minutes (UTC, the default)
telbase deploy --schedule "*/15 * * * *"

Flags

Automatic detection
Telbase detects worker patterns in your code and classifies them as daemon (runs forever) or task (runs and exits). Task workers get --schedule suggested automatically. Daemon workers get Always On suggestions instead — deploying a daemon with --schedule will cause it to be killed at the timeout limit.

Daemon vs Task Workers

Not all background workers should be scheduled jobs. Telbase scans your code for long-running patterns and classifies workers into two types:

TypeExamplesDeploy asMonthly cost
DaemonAPScheduler, Celery Beat, node-cron, while TrueAlways On service~$10/mo
TaskPython scripts, management commands, one-off processors--schedule (Cloud Run Job)~$0.75/mo
First in market
Telbase is the only deployment platform that auto-detects worker patterns. Heroku, Railway, Render, Fly.io, and GCP all require you to manually declare the workload type via Procfile, YAML config, or dashboard selection.

Deploying a Daemon Worker

If Telbase detects a daemon pattern, deploy as a regular Cloud Run Service with Always On enabled:

  1. Deploy without --schedule — this deploys as a Cloud Run Service (not a Job).
  2. Add a health endpoint if your worker doesn't serve HTTP. Cloud Run requires a process listening on $PORT:
python
# Add to your worker entrypoint — Cloud Run requires $PORT listener
import threading, http.server, os
threading.Thread(target=lambda: http.server.HTTPServer(
    ('', int(os.environ.get('PORT', 8080))),
    http.server.BaseHTTPRequestHandler
).serve_forever(), daemon=True).start()
  1. Enable Always On in Dashboard → Settings, or via POST /projects/:id/warm-start. Without Always On, Cloud Run scales to zero on idle — killing the daemon.
Duplicate execution risk
If Cloud Run scales to multiple instances, you get multiple scheduler daemons running the same jobs. Make jobs idempotent, or embed the scheduler in your API process via FastAPI lifespan.

Refactoring Daemons to Scheduled Tasks

If all your daemon's jobs are periodic (hourly, daily, weekly), you can refactor to a one-shot dispatcher. Each invocation runs, does its work, and exits — 10-100x cheaper than Always On for infrequent work.

python
# worker.py — one-shot dispatcher for Cloud Run Jobs
import sys
from tasks import fetch_data, generate_report, sync_inventory

dispatch = {"fetch": fetch_data, "report": generate_report, "sync": sync_inventory}
task = sys.argv[1] if len(sys.argv) > 1 else "fetch"
dispatch[task]()
bash
telbase deploy --schedule "0 * * * *" --command "python worker.py fetch"
When to stay Always On
Sub-5-minute intervals, stateful schedulers, or workers that need persistent connections (queues, WebSockets). The cold-start overhead of Cloud Run Jobs exceeds the savings at high frequency.

Managing Jobs

After deploying, manage your job from the dashboard or CLI.

Dashboard

The Jobs tab shows your schedule (in human-readable format), a Run Now button for manual triggers, and a toggle to pause/resume the schedule.

CLI

bash
# Manually trigger an execution
telbase run

# Trigger and stream logs in real-time
telbase run --follow

# Update the schedule (redeploy with new cron)
telbase deploy --schedule "0 12 * * *"

API

Execution History

View past executions and their status from the CLI or dashboard.

bash
# Show recent execution history
telbase logs --executions

The dashboard Jobs tab displays each execution with a color-coded status indicator, duration, and a link to view logs.

StatusMeaning
SUCCEEDEDCompleted successfully (exit code 0)
FAILEDExited with non-zero status or error
RUNNINGCurrently executing
PENDINGQueued, waiting to start
CANCELLEDStopped before completion

Circuit Breaker

If your job fails 5 consecutive times, Telbase automatically pauses the schedule and sends you an email notification. This prevents runaway costs from a broken job.

To resume: fix the underlying issue, then click Resume in the dashboard or call POST /projects/:id/schedule/resume.

Fix before resuming
The circuit breaker resets after a successful execution. If you resume without fixing the issue, the breaker will trip again after 5 more failures.

Pricing

Each scheduled job uses one slot. Slots are included in your plan. Extra slots and execution compute are charged via credits.

PlanIncluded SlotsMax TimeoutExtra Slot Cost
Free0 (not available)
Starter ($5/mo)15 minutes20 credits/mo ($2)
Builder ($19/mo)310 minutes20 credits/mo ($2)
Pro ($79/mo)1030 minutes20 credits/mo ($2)

Execution compute: 1 credit = 25 compute-minutes. Fractional credits accumulate within a billing cycle.

Cost example
A daily job that runs for 2 minutes costs approximately 2.4 credits/month ($0.24) in compute. Compare this to an always-on worker at $10/mo — scheduled jobs are dramatically cheaper for periodic workloads.

Cron Syntax Reference

Telbase uses standard 5-field cron format: minute hour day month weekday.

ExpressionMeaning
0 * * * *Every hour at minute 0
*/15 * * * *Every 15 minutes
0 9 * * *Daily at 9:00 AM
0 9 * * 1-5Weekdays at 9:00 AM
0 0 1 * *First day of every month at midnight
30 2 * * 0Sundays at 2:30 AM

MCP Tools

When using Claude Code with the Telbase MCP server, five tools are available for scheduled jobs:

Next Steps