Skip to content

Run a script on a schedule from your AI agent, with no server

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

By Aloïs Oddon, co-founder of Nextmap. Facts checked on November 2, 2026.

View as Markdown

Prerequisites

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

Step 1: Give your agent these instructions

Open your agent in your script’s folder, and paste these instructions into it:

Instructions
Connect to while with my account (while.sh/agents), then deploy my app.

Your agent 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 agent tells you when the script will run, and gives you the result of each run.

What your agent does

It writes while.yaml next to your script:

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 am1. A run that ends with exit code 0 has succeeded.

Run the script right now

You, to your agent: Run the report now.

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

Know whether everything went well

You, to your agent: 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 agent.

Catch up on a missed period

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

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

Add a database

You, to your agent: Add a PostgreSQL database.

Your agent declares the database in while.yaml, and its address reaches your code in DATABASE_URL. It’s backed up every day, and can go back to a precise moment if needed.

In the docs: Scheduled jobs, Data projects, PostgreSQL databases and Valkey cache (Redis).

Next steps

Sources

  1. The Linux manual, crontab(5), the five fields of a cron line, accessed November 1, 2026

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.

Connect your agent, it takes care of the rest

To paste into your agent

Read while.sh/agents, then deploy my app with while.

Copy the instructions

No account needed to try: your app is live right away. To keep it, sign in.

A project for your company? Talk to the team: hello@while.sh