DEV Community

Cover image for How to Run Cron Jobs in Deno Without a Server Using Deno Deploy and Webhooks
HexShift
HexShift

Posted on

How to Run Cron Jobs in Deno Without a Server Using Deno Deploy and Webhooks

Cron jobs are vital for running background tasks at scheduled intervals. While traditional methods involve servers or managed services, Deno Deploy provides a free, serverless, and modern way to achieve this using webhooks and scheduled triggers from external services like GitHub Actions or Upstash.

Why Deno Deploy?

  • Zero configuration serverless functions
  • Support for TypeScript out of the box
  • Free tier with edge deployment

How It Works

Deno Deploy doesn’t have native scheduled triggers (yet), but you can still implement cron behavior by:

  1. Deploying a Deno endpoint
  2. Using GitHub Actions or Upstash Scheduler to ping it on a schedule

Step 1: Set Up a Deno Project

// main.ts import { serve } from "https://deno.land/std/http/server.ts"; serve(async (req: Request) => { const url = new URL(req.url); if (url.pathname === "/run-cron") { // Perform your task here console.log("Cron job triggered:", new Date().toISOString()); // Example: Fetching and cleaning up data const data = await fetch("https://your-api.com/clean"); const result = await data.text(); return new Response(`Cron ran: ${result}`); } return new Response("OK"); }); 

Step 2: Deploy to Deno Deploy

Push your code to a GitHub repository, then visit deno.com/deploy to link your GitHub account and deploy your project. You'll get a public URL like:

https://your-cron.deno.dev/run-cron

Step 3: Use GitHub Actions as the Scheduler

Add this GitHub Actions workflow in your repo:

# .github/workflows/schedule.yml name: Trigger Deno Cron on: schedule: - cron: "*/15 * * * *" # every 15 minutes workflow_dispatch: jobs: ping-cron: runs-on: ubuntu-latest steps: - name: Curl to Deno run: curl -X GET https://your-cron.deno.dev/run-cron 

Push to GitHub, and the cron will start triggering your endpoint.

Pros and Cons

✅ Pros

  • Zero-cost setup using Deno and GitHub
  • No infrastructure to manage
  • Easy to deploy and maintain

⚠️ Cons

  • Depends on an external scheduler (e.g., GitHub Actions)
  • No native time-based triggers inside Deno Deploy
  • Limited logging/debugging from GitHub side

🚀 Alternatives

  • Upstash Scheduler: Free HTTP-based cron trigger
  • Cloudflare Workers: Native scheduled events
  • GitHub Actions Only: Run full tasks entirely in workflows

Conclusion

While Deno Deploy doesn’t support built-in cron jobs yet, you can easily pair it with free schedulers like GitHub Actions to create a powerful, serverless cron system. This lets you keep your infrastructure clean and modern — and your wallet untouched.

If this article helped, you can support more like it at: buymeacoffee.com/hexshift

Top comments (0)