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.
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:
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:
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
- The Linux manual, crontab(5), the five fields of a cron line, accessed November 1, 2026