Ben Borgers

How to set up a cron job for your Glitch project

May 3, 2020

A cron job allows you to run some code on a schedule (every day at 9am, every hour at 10 minutes past the hour, etc).

With Glitch, you can do that by writing the code in your Glitch project, and then triggering the code to run externally.

First, set up an Express route that contains the code you want to run:

app.get("/cron", (req, res) => {
  // the code you want to run

  res.sendStatus(200) // sends an "OK" response

This means that when you go to in your browser, the code will execute.

Now, instead of opening that page manually, we’ll use an external service to make an HTTP request to the /cron endpoint and run that code.

Go to and sign up (it’s free). Then, view your cron jobs and click the “Create” button.

Give the job a name that describes it, and put the URL as the one where a request should be made.

Configure the schedule options so it runs at the frequency you’d like, and click “Create cronjob” at the bottom of the page.

Done! Now, will make an HTTP request to that URL at the frequency you told them to, triggering the code in the /cron route to run automatically.

Subscribe to my newsletter!

A weekly round-up of new blog posts and updates to projects I’m working on.