Skip to main content

Command Palette

Search for a command to run...

Auto Update Downloaded Ollama Models

Updated
1 min read
Auto Update Downloaded Ollama Models
H

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 :-)

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

More from this blog

Hong's Tech Blog

110 posts

The blog is older than you know. I prefer counting from the emergence of one integral anomaly to the emergence of the next, in which case this is the forth version.