Auto Update Downloaded Ollama Models

HongHong
1 min read

I like to keep all models updated, but Ollama does not automatically update downloaded models. This is how I automate updates using a cronjob and Bash script.

~/.local/bin/update-models.sh

#!/usr/bin/env bash

# Update all local models.
models=$(ollama ls | tail -n +2 | awk '{print $1}')

for model in $models
do
    echo "Pulling ${model}"
    ollama pull $model
done

Run it after 12 AM daily. I introduced delay execution in this blog post.

0    0    *    *    *    sleep $((RANDOM % 3600)); ~/.local/bin/update-models.sh > /dev/null 2>&1
0
Subscribe to my newsletter

Read articles from Hong directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Hong
Hong

I am a developer from Malaysia. I work with PHP most of the time, recently I fell in love with Go. When I am not working, I will be ballroom dancing :-)