How to pause and resume a resource-intensive process on Linux with SIGSTOP: specifically, Ollama LLM inference
Keep your system resources to yourself when you need them, and put them to good use when you don’t
Yesterday, I wrote about how to run OCR with local vision models and Ollama. One of the main drawbacks of running local LLMs with Ollama (or any other tool) is that they’re almost comically resource-hungry.
It’s hard to run LLM inference “in the background” while doing other things. The fans rev up, the keyboard deck grows warm to the touch, and sometimes the whole system freezes.
I have tried limiting the Ollama’s RAM usage with ulimit, and systemd memory limits (systemd-run –scope -p MemoryMax=12G –user ollama run qwen3-vl), but it needs the memory. And I’ve tried reniceing it to lowest priority, but the fans still get noisy.
Now, I have better solution: pause inference when I’m using my laptop, and resume when I get up to get a snack or go for a run.
I’ve known, for a while, about Ctrl+Z, and had the vague sense that jobs must be able to be stopped and resumed, in cases where this is possible.
Today, I bothered to look it up, and learn about the graceful request, 20 SIGTSTP, and the forceful order 19 SIGSTOP, both of which are resumed with 18 SIGCONT.
(Full table of signal numbers can be found here.)
However.
When I tried these in htop, they didn’t work. There are many different processes. There’s the ollama server, the ollama runner, ollama run, and the rest of the pipeline that started the workload. Take a look!
ps aux | grep ollama
Which one is actually relevant?
I tried several things that didn’t work. (If you want the spinner to freeze, stop the ollama run command :)
What I learned:
- The heavy resource usage is from the runner process(es)
- The serve and runner processes cannot be paused and resumed without using sudo
- Memory remains tied up while the process is stopped (the same amount, or just some?). It would be cool if there was a way to write this to disk and then load it back into RAM.
- Ollama doesn’t listen to Terminal Stop (SIGTSTP, -TSTP, -20)
- One time, using SIGSTOP resulted in losing one page of the OCR pipeline. I don’t understand why: obviously the Ollama process didn’t like being put on ice. When I tried to get this to happen again, no pages were lost.
Here’s the command I ended up using.
sudo killall -STOP ollama
(Confirm it worked by listening to the fans spin down, seeing the resource usage and load average drop in htop, and running ps aux | grep ollama and again an seeing that there’s a T added to column 5; or run ps -p $(pidof ollama) -o pid,stat,cmd and the T will be in the STAT column)
Then, when I’m done using my laptop, and want to put those idle clock cycles to use, I run:
sudo killall -CONT ollama
It’s pretty handy!