[GH-ISSUE #5165] difference between systemctl start/restart ollama and ollama serve? #29014

Closed
opened 2026-04-22 07:36:13 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @swlee9087 on GitHub (Jun 20, 2024).
Original GitHub issue: https://github.com/ollama/ollama/issues/5165

Hi! Per the title, I was having issues with the Ollama server shutting down even after I meddled with the ollama.service variables.

ollama.service is now like this:

[Unit]
Description=Ollama Service
After=network-online.target

[Service]
ExecStart=/usr/local/bin/ollama serve
User=ollama
Group=ollama
Restart=always
RestartSec=3
Environment="PATH=/ollama_api/ollama_env/bin:/root/.nvm/versions/node/v16.20.2/bin:/root/.local/bin:/root/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/usr/local/tibero7/bin:/usr/local/tibero7/client/bin"
Environment="OLLAMA_HOST=0.0.0.0:11434"
Environment="OLLAMA_NUM_PARALLEL=2"
Environment="OLLAMA_MAX_LOADED_MODELS=2"
Environment="OLLAMA_KEEP_ALIVE=10m"

[Install]
WantedBy=default.target

But it is only effective when I speifically run systemctl start/restart ollama.
Otherwise, when I run OLLAMA_HOST=0.0.0.0:11434 ollama serve, the changes are not applied, and my models are all saved inside this way.
I could set the models directory inside ollama.service OR recreate all my models inside the systemctl method and get over it, but I want to understand why thsi is happening. This is not mentioned anywhere in the FAQ or documents.

Originally created by @swlee9087 on GitHub (Jun 20, 2024). Original GitHub issue: https://github.com/ollama/ollama/issues/5165 Hi! Per the title, I was having issues with the Ollama server shutting down even after I meddled with the ollama.service variables. ollama.service is now like this: ```bash [Unit] Description=Ollama Service After=network-online.target [Service] ExecStart=/usr/local/bin/ollama serve User=ollama Group=ollama Restart=always RestartSec=3 Environment="PATH=/ollama_api/ollama_env/bin:/root/.nvm/versions/node/v16.20.2/bin:/root/.local/bin:/root/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/usr/local/tibero7/bin:/usr/local/tibero7/client/bin" Environment="OLLAMA_HOST=0.0.0.0:11434" Environment="OLLAMA_NUM_PARALLEL=2" Environment="OLLAMA_MAX_LOADED_MODELS=2" Environment="OLLAMA_KEEP_ALIVE=10m" [Install] WantedBy=default.target ``` But it is only effective when I speifically run `systemctl start/restart ollama`. Otherwise, when I run `OLLAMA_HOST=0.0.0.0:11434 ollama serve`, the changes are not applied, and my models are all saved inside this way. I could set the models directory inside ollama.service OR recreate all my models inside the systemctl method and get over it, but I want to understand why thsi is happening. This is not mentioned anywhere in the FAQ or documents.
Author
Owner

@Speedway1 commented on GitHub (Jun 20, 2024):

ollama serve: Runs as a process in your login shell. If you log out, it ends.

systemctl start/restart ollama: Runs Ollama as a "service" on your machine, turning your machine into an Ollama server that doesn't need you logged into it for Ollama to be running.

Use "ollama serve" for when you are running it personally and at that moment in time only.
Use "systemctl start/restart ollama" for Ollama to always be there when you need it and avilable from other machines in your home, office, network.

<!-- gh-comment-id:2180300482 --> @Speedway1 commented on GitHub (Jun 20, 2024): ollama serve: Runs as a process in your login shell. If you log out, it ends. systemctl start/restart ollama: Runs Ollama as a "service" on your machine, turning your machine into an Ollama server that doesn't need you logged into it for Ollama to be running. Use "ollama serve" for when you are running it personally and at that moment in time only. Use "systemctl start/restart ollama" for Ollama to always be there when you need it and avilable from other machines in your home, office, network.
Author
Owner

@jmorganca commented on GitHub (Jun 20, 2024):

Thanks for the issue! As mentioned by @Speedway1:

  • systemctl restart ollama starts or restarts Ollama as a system service (using systemd)
  • ollama serve is what actually runs Ollama (this is what the above command ultimately runs)
<!-- gh-comment-id:2180855661 --> @jmorganca commented on GitHub (Jun 20, 2024): Thanks for the issue! As mentioned by @Speedway1: * `systemctl restart ollama` starts or restarts Ollama as a system service (using systemd) * `ollama serve` is what actually runs Ollama (this is what the above command ultimately runs)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#29014