RUNLOCALAIv38
->Will it run?Best GPUCompareTroubleshootStartLearnPulseModelsHardwareToolsBench
Run check
RUNLOCALAI

Independently operated catalog for local-AI hardware and software. Hand-written verdicts. Source-cited claims. Reproducible commands when we have them.

OP·Eruo Fredoline
DIR
  • Models
  • Hardware
  • Tools
  • Benchmarks
TOOLS
  • Will it run?
  • Compare hardware
  • Cost vs cloud
  • Choose my GPU
  • Prompting kits
  • Quick answers
REF
  • All buyer guides
  • Learn local AI
  • Methodology
  • Glossary
  • Errors KB
  • Trust
EDITOR
  • About
  • Author
  • How we make money
  • Editorial policy
  • Contact
LEGAL
  • Privacy
  • Terms
  • Sitemap
MAIL · MONTHLY DIGEST
Get monthly local AI changes
Monthly recap. No spam.
DISCLOSURE

Some links on this site are affiliate links (Amazon Associates and other first-class retailers). When you buy through them, we earn a small commission at no extra cost to you. Affiliate links do not influence our verdicts — there are cards we rate highly that we don't have affiliate relationships with, and cards that sell well that we refuse to recommend. Read more →

© 2026 runlocalai.coIndependently operated
RUNLOCALAI · v38
  1. >
  2. Home
  3. /Learn
  4. /How-to
  5. /How to run a model in the background as a persistent service
HOW-TO · INF

How to run a model in the background as a persistent service

intermediate·10 min·By Eruo Fredoline
Target environment
Ubuntu 24.04 · Ollama 0.4.x
PREREQUISITES

Ollama installed, model already pulled to local library

What this does

Converts the Ollama server into a background service that remains available across terminal sessions, reboots, and logout events. After this guide the model API will be accessible without manual intervention.

Steps

  1. Launch the Ollama server with nohup backgrounding. Detaches the process from the controlling terminal so it persists after logout.

    nohup ollama serve > /tmp/ollama.log 2>&1 &
    

    Expected output: A process ID printed by the shell.

  2. Verify the server is listening. Confirms the server is accepting connections on port 11434.

    ss -tlnp | grep 11434
    

    Expected output: A line showing LISTEN state on port 11434 with the Ollama PID.

  3. Set up a systemd service for automatic startup. Creates a unit file that survives reboots.

    sudo tee /etc/systemd/system/ollama.service << 'EOF'
    [Unit]
    Description=Ollama Server
    After=network-online.target
    Wants=network-online.target
    

[Service] ExecStart=/usr/local/bin/ollama serve Environment=OLLAMA_HOST=0.0.0.0 Restart=always RestartSec=3

[Install] WantedBy=multi-user.target EOF


4. **Enable and start the service.** Reloads systemd configuration, enables auto-start, and launches the server.
```bash
sudo systemctl daemon-reload && sudo systemctl enable ollama && sudo systemctl start ollama

Expected output: No errors; systemctl status shows "active (running)".

Verification

curl http://localhost:11434/api/tags
# Expected: JSON array containing model entries with "name" and "size" fields

Common failures

  • address already in use - Port 11434 is occupied by another process; kill it with fuser -k 11434/tcp.
  • Environment=OLLAMA_HOST ignored - Variable placed in wrong systemd section; must be under [Service].
  • permission denied - User lacks write access to the log directory; use /tmp/ollama.log or adjust permissions.
  • service starts then dies - ExecStart path is incorrect; verify with which ollama.

Operator checkpoint

Before treating this as solved, write down the local runtime, model or package version, hardware/backend if relevant, and the verification output. This keeps the guide useful as a Will-It-Run style decision instead of a one-off command transcript.

Related guides

  • How to configure the Ollama serve port for network access
  • How to stop a running model and free up memory
RELATED GUIDES
INF
How to configure the Ollama serve port for network access
INF
How to stop a running model and free up memory
← All how-to guidesCourses →