New Tool Radar

AI Agents & Automation

How to Run a Local Ollama Agent Task on a Schedule With a Cron Script

Write a small script that asks a local Ollama model to do one job, and run it on a cron schedule so it happens every morning.

Schematic diagram with three steps: Write the script, Test it by hand, then Add the cron line.

A local agent does not need a server to run on a schedule: a small script can send one prompt to the local Ollama API, save the reply, and exit. Cron runs that script at a fixed time, which gives you a daily agent task with no hosted service involved.

Before you start

You need Ollama running locally with a model pulled, and a folder where the script can save its output. Decide the one job first, for example summarising a local file, and keep it to a single prompt.

Write the script and test it by hand

Write a script that reads the input, sends one chat request to the local Ollama API, and writes the reply to a dated file. Run it by hand twice and read both outputs: a scheduled job that fails silently is worse than no job at all.

Add the cron line and check the first scheduled run

Add a cron line for the time you want, for example 07:00 every weekday, pointing at the script. Wait for the first scheduled run and check the output file exists and reads correctly. If the file is missing, check the cron log: the usual cause is a path that only works in an interactive shell.

Worked example: A daily summary for a fictional notes desk

Maple Notes is a fictional notes desk. A cron script summarises the previous day notes file every weekday at 07:00. The table shows one week.

Date Input file Summary written?
Monday 7 December 2026 notes-2026-12-06.txt Yes
Tuesday 8 December 2026 notes-2026-12-07.txt Yes
Wednesday 9 December 2026 notes-2026-12-08.txt Yes

Expected result (UNTESTED): three summary files appear, one per morning, each naming the notes file it summarised. We checked the Ollama local-model documentation summary, which describes the local chat API, but we did not run the cron script on this machine.

Limits

Cron runs without a human watching, so a bad prompt produces a bad summary every morning until someone checks. Log each run and read the output for the first week. Keep the script to one prompt: a scheduled loop of agent calls is a cost and a risk.

Sources

See all