Why use systemd?

Running Odoo directly in the terminal means it stops when you close the SSH session. systemd solves this by managing Odoo as a proper Linux service.

🔄 Auto-restart
Automatically restarts Odoo if it crashes or exits unexpectedly
⚡ Boot startup
Starts Odoo automatically when the server reboots
📋 Centralized logs
All output captured by journalctl, available system-wide
🔒 Dependency ordering
Ensures PostgreSQL is running before Odoo starts

Create the Service File

Create the systemd unit file at /etc/systemd/system/odoo.service.

bash
sudo nano /etc/systemd/system/odoo.service

Paste the following unit configuration.

ini
[Unit]
Description=Odoo
Documentation=https://www.odoo.com/documentation
After=network.target postgresql.service
Requires=postgresql.service

[Service]
Type=simple

User=odoo
Group=odoo

WorkingDirectory=/opt/odoo/community
Environment="PATH=/opt/odoo/venv/bin"

ExecStart=/opt/odoo/venv/bin/python3 /opt/odoo/community/odoo-bin \
    -c /etc/odoo/odoo.conf

Restart=always
RestartSec=5
TimeoutStopSec=60

StandardOutput=journal
StandardError=journal

[Install]
WantedBy=multi-user.target
Virtual environment in ExecStart

Using the full path to the virtual environment's Python interpreter ensures Odoo always runs with the correct Python version and all installed packages, regardless of what is set in PATH.

Directive Reference

DirectiveValuePurpose
After=postgresql.serviceStart Odoo only after PostgreSQL is ready
Requires=postgresql.serviceStop Odoo if PostgreSQL stops
User / GroupodooRun the process as the non-root odoo user
Environment=PATHvenv bin dirEnsure the virtual environment executables are used
Restart=alwaysRestart automatically after any exit
RestartSec=55 secondsWait 5 seconds before attempting restart
TimeoutStopSec=6060 secondsAllow up to 60 seconds for graceful shutdown
StandardOutput=journalSend stdout to systemd journal (accessible via journalctl)

Enable and Start the Service

Reload systemd to pick up the new unit file, then enable and start the service.

bash
sudo systemctl daemon-reload

sudo systemctl enable odoo

sudo systemctl start odoo

Useful Service Commands

bash
sudo systemctl status odoo --no-pager

sudo systemctl restart odoo

sudo systemctl stop odoo

journalctl -u odoo -n 50 --no-pager

journalctl -u odoo -f

Verification

bash
sudo systemctl is-enabled odoo
sudo systemctl status odoo --no-pager
curl -I http://127.0.0.1:8069/web/login
  • systemctl is-enabled odoo returns enabled
  • systemctl status odoo shows active (running)
  • curl to port 8069 returns HTTP 200 or 303
  • Logs visible via journalctl -u odoo

Common Issues

ProblemLikely CauseResolution
Service fails immediatelyIncorrect ExecStart pathVerify the virtual environment Python path: which python inside source venv/bin/activate
Permission deniedWrong file ownershipEnsure /opt/odoo and /etc/odoo are owned by the odoo user
Python module missingWrong interpreterConfirm ExecStart uses the venv Python, not /usr/bin/python3
PostgreSQL not foundDB service not startedRun sudo systemctl start postgresql first
Never run Odoo as root

Running Odoo as the root user is a significant security risk. Always use a dedicated odoo Linux user with only the minimum permissions required.

Back to top