[GH-ISSUE #10108] Gracefully terminate a background ollama serve process via a ollama command #68686

Closed
opened 2026-05-04 14:50:47 -05:00 by GiteaMirror · 3 comments
Owner

Originally created by @vadimkantorov on GitHub (Apr 3, 2025).
Original GitHub issue: https://github.com/ollama/ollama/issues/10108

I've run ollama serve &> ollama.log.txt &, but somehow I cannot fg it again (maybe because I did this inside screen and screen got terminated for some reason), but it's still running in the background in ps aux | grep ollama.

Is there a way to run some ollama command to gracefully stop serving? (besides killing the process: I've read reports online that this might sometimes orphan the runners / keep VRAM hanging)

Originally created by @vadimkantorov on GitHub (Apr 3, 2025). Original GitHub issue: https://github.com/ollama/ollama/issues/10108 I've run `ollama serve &> ollama.log.txt &`, but somehow I cannot `fg` it again (maybe because I did this inside `screen` and `screen` got terminated for some reason), but it's still running in the background in `ps aux | grep ollama`. Is there a way to run some `ollama` command to gracefully stop serving? (besides killing the process: I've read reports online that this might sometimes orphan the runners / keep VRAM hanging)
GiteaMirror added the feature request label 2026-05-04 14:50:47 -05:00
Author
Owner

@rick-github commented on GitHub (Apr 3, 2025):

Send a signal to the process group, which is the negative of the main process.

$ ps wufax | grep ollama
rick     1468719  0.0  0.0  14864  2112 pts/6    S+   12:20   0:00  |   \_ grep --color=auto ollama
rick     1468623  5.1  0.1 7217124 104820 pts/7  Sl+  12:20   0:00      \_ ollama serve
rick     1468683  3.5  0.4 2776408 483780 pts/7  Sl+  12:20   0:00          \_ /usr/local/bin/ollama runner 
$ kill -HUP -1468623
$ ps wufax | grep ollama
rick     1469144  0.0  0.0  14864  2112 pts/6    S+   12:24   0:00  |   \_ grep --color=auto ollama

Or just send a signal to all ollama processes. Note, this will stop any other ollama processes being run by you:

 $ kill -HUP $(pidof ollama)
<!-- gh-comment-id:2775266074 --> @rick-github commented on GitHub (Apr 3, 2025): Send a signal to the process group, which is the negative of the main process. ```sh $ ps wufax | grep ollama rick 1468719 0.0 0.0 14864 2112 pts/6 S+ 12:20 0:00 | \_ grep --color=auto ollama rick 1468623 5.1 0.1 7217124 104820 pts/7 Sl+ 12:20 0:00 \_ ollama serve rick 1468683 3.5 0.4 2776408 483780 pts/7 Sl+ 12:20 0:00 \_ /usr/local/bin/ollama runner $ kill -HUP -1468623 $ ps wufax | grep ollama rick 1469144 0.0 0.0 14864 2112 pts/6 S+ 12:24 0:00 | \_ grep --color=auto ollama ``` Or just send a signal to all ollama processes. Note, this will stop any other ollama processes being run by you: ```sh $ kill -HUP $(pidof ollama) ```
Author
Owner

@vadimkantorov commented on GitHub (Apr 3, 2025):

A related function in nginx: https://docs.nginx.com/nginx/admin-guide/basic-functionality/runtime-control/

One can use sudo nginx -s stop to gracefully terminate the server

<!-- gh-comment-id:2776357160 --> @vadimkantorov commented on GitHub (Apr 3, 2025): A related function in `nginx`: https://docs.nginx.com/nginx/admin-guide/basic-functionality/runtime-control/ One can use `sudo nginx -s stop` to gracefully terminate the server
Author
Owner

@vadimkantorov commented on GitHub (Apr 30, 2025):

There are tons of workarounds, but it would be much nicer if one of them operated as Ollama command.

Service control binaries servicectl, Nginx or others do typically have a stop verb for graceful termination

New users will keep asking for this function likely...

<!-- gh-comment-id:2842506996 --> @vadimkantorov commented on GitHub (Apr 30, 2025): There are tons of workarounds, but it would be much nicer if one of them operated as Ollama command. Service control binaries `servicectl`, Nginx or others do typically have a `stop` verb for graceful termination New users will keep asking for this function likely...
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#68686