Hand this tutorial to your agent in one click

A key section of this article is locked, and an agent opening the link cannot see it either. Unlock it first, then copy the full text for your agent in one click.

Run Scheduled Tasks With Zero Tokens Using a System Timer

Intermediate tutorial: Don't have the Agent run scheduled tasks by hand every day. Have it write the task as one Python script, hand it to the system's built-in cron or Task Scheduler, and run it at 0 Tokens per run. When the script finishes, it sends you a message saying whether it succeeded or failed.

Machine translation. Read the original

Why do it this way

Many people have an Agent do recurring work every day: pull data, compile reports, back up files, check websites. If the Agent runs every time, each run costs Tokens, which adds up to a lot over a month, and the Agent's execution may not be the same each time.

A better approach:

  • Have the Agent do the work once: write the task as a Python script. This costs some Tokens, one time.
  • Then hand the script to the system's built-in scheduler. It doesn't go through the AI, so each run costs 0 Tokens.
  • When the script finishes, it messages you the result, so you know whether it succeeded or failed.

The result: stable execution, predictable output, and almost no cost.

Step 1: Have the Agent write the task as a script

Say this to your Agent (Claude Code, Codex, etc.):

Sign in to unlock this key section

New accounts get 10 free credits, plus 1 more for each daily check-in. Spend 1 credit to unlock and it stays open for you.

The script it produces will look roughly like this:

import os, json, time, urllib.request, urllib.parse

def notify(text):
    token = os.environ["TG_BOT_TOKEN"]
    chat = os.environ["TG_CHAT_ID"]
    data = urllib.parse.urlencode({"chat_id": chat, "text": text}).encode()
    urllib.request.urlopen(f"https://api.telegram.org/bot{token}/sendMessage", data, timeout=10)

def run():
    start = time.time()
    with urllib.request.urlopen("https://example.com", timeout=15) as r:
        return r.status, round(time.time() - start, 2)

try:
    status, seconds = run()
    notify(f"✅ Website check complete: status {status}, took {seconds} seconds")
except Exception as e:
    notify(f"❌ Website check failed: {e}")

Run it manually once first to confirm you receive the message:

python3 /full/path/task.py

Step 2: Hand it to the system to run on a schedule

macOS / Linux: use cron

crontab -e

Add a line (runs every day at 9 AM):

0 9 * * * TG_BOT_TOKEN=your_token TG_CHAT_ID=your_id /usr/bin/python3 /full/path/task.py >> /full/path/task.log 2>&1

The first five fields are, in order: minute, hour, day, month, weekday. 0 9 * * * means every day at 9:00.

Windows: use Task Scheduler

schtasks /create /tn "DailyTask" /tr "python C:\full\path\task.py" /sc daily /st 09:00

Set the environment variables in "System Properties → Environment Variables".

Step 3: Confirm it is actually running

  • The next day, check whether the message arrived on your phone.
  • If not, check the errors in task.log.
  • Use the full path in cron commands: cron's environment is very bare, so python3 and your file paths may not be found. Use which python3 to find Python's full path.
  • On macOS, if the script reads or writes certain folders (such as Desktop or Documents), you may need to grant cron "Full Disk Access".

When you still need AI

  • When the task requires understanding content: for example, summarizing an article or deciding how to reply to an email. Only that part calls the model; the other steps still use the script.
  • When requirements change: have the Agent update the script once, then keep running it at 0 Tokens.

If a task can be written as fixed steps, don't let AI improvise it every time.

Further reading

Done with this one? Mark it to track your path.Sign in
Save it for laterSign in
Questions about this piece?Ask AI about this

Comments (0)

No comments yet. Start the conversation.

Sign in to join the discussion.Sign in