---
title: "Run a cron job in 2026: a script at a set time, with no server"
url: https://while.sh/en/guides/run-cron-job/
author: "Aloïs Oddon, co-founder of Nextmap"
updated: 2026-11-19
---

# Run a script at a set time with your AI, with no server (2026)

A report every morning, an import every night? Tell your AI the time: connected to while over MCP, it schedules your script, and you always know whether it ran.

> **The short version.** Over MCP, your AI schedules your script for whatever time you want. Every run is tracked, and a failure alerts your AI. No server. What matters, like deleting a database, waits for a person's approval.

## Prerequisites

- A Python, Node.js or Go script, with its requirements.txt, its package.json or its go.mod: your AI adds it if it's missing.
- An AI that works in a terminal: Claude Code, Codex, Cursor or Gemini CLI.

## Step 1: Give your AI this message

Open your AI in your script's folder, and paste this message into it:

```text titre="The message to give your AI"
Connect to while with my account (while.sh/agents), then put my app on while.
```

Your AI adds while's MCP server itself. If it asks you to, restart it. On the first call to while, a page opens in your browser. In Claude Code, if it doesn't open, type /mcp, choose while, then Authenticate. On that page, choose "A new app", then click Authorize.

## Step 2: Follow the runs

Your AI tells you when the script will run, and gives you the result of each run.

## What your AI does

It writes while.yaml next to your script:

```yaml titre="while.yaml"
apiVersion: while/v1
project: mon-script
crons:
  - name: rapport
    schedule: "0 7 * * *"
    timezone: Europe/Paris
    command: [python, rapport.py]
    source: .
```

The schedule reads in one line: `0 7 * * *` means every day at 7 am (source 1). A run that ends with exit code 0 has succeeded.


<figure class="illus"><img src="/illustrations/guide-fonction-garde-1200.webp" srcset="/illustrations/guide-fonction-garde-768.webp 768w, /illustrations/guide-fonction-garde-1200.webp 1200w" sizes="(min-width: 48rem) 46rem, 100vw" width="1536" height="1024" loading="lazy" decoding="async" alt="A script at a set time with while: credentials kept out of the AI's reach, every call logged in the history, a person's approval for what matters and a daily backup, in France" /><figcaption>Around every app, while keeps the credentials, the history, the approvals and the backups.</figcaption></figure>

## Run the script right now

> You, to your AI: Run the report now.

Your AI starts a run without waiting for the scheduled time, and gives you its result.

## Know whether everything went well

> You, to your AI: Did this morning's report go out?

Every run is recorded with its duration, its exit code and the last lines of its log. A run that fails or is missed alerts your AI.

## Catch up on a missed period

> You, to your AI: Rerun the import for the last three days.

Your AI reruns the job over that period: your script receives its start and end dates, and your AI writes it to process only those dates.

## Add a database

> You, to your AI: Add a PostgreSQL database.

Your AI declares the database in while.yaml, and its address reaches your code in `DATABASE_URL`. The database is backed up every day, with a way back to a precise moment over 14 days.

## Next steps

- [Deploy a Node.js API and its PostgreSQL database](/en/guides/deploy-node-api-postgresql/)
- [Add a Redis-compatible cache](/en/guides/add-redis-cache/)
- [Compare the hosts that have an MCP server](/en/comparisons/mcp-hosting-claude-code/)

## Sources

1. [The Linux manual, crontab(5), the five fields of a cron line](https://man7.org/linux/man-pages/man5/crontab.5.html), 2026-11-01

## Questions

### Can my script read my app's database?

Yes, it receives the same variables as your app, database address included.

### Who can open my script from the internet?

Nobody: a scheduled job has no public address.

### In which time zone?

The one you choose, Paris time by default.

### Where do my app and its data run?

In France, at Nextmap. The database is backed up every day, with a way back over 14 days, once a person approves.

### Does my AI see my credentials?

No. You paste them into while, the app uses them, and your AI never sees them. Every call is logged.
