## Overview This guide explains how to configure [Glances](https://nicolargo.github.io/glances/) to run automatically on system startup in web server mode on Ubuntu systems. Glances is a cross-platform system monitoring tool that provides a wealth of information about your system resources. ## Prerequisites - Ubuntu 24.04 or similar - Glances installed via pipx - Administrative (sudo) access ## Installation (If Not Already Done) If you haven't already installed Glances: ```bash # Install pipx if needed sudo apt update sudo apt install pipx pipx ensurepath # Install Glances pipx install glances ``` ## Creating a Systemd Service To make Glances start automatically on boot, you need to create a systemd service file. ### Step 1: Create the Service File ``` sudo nano /etc/systemd/system/glances.service ``` ### Step 2: Add the Configuration Add the following content to the file: > [!IMPORTANT] Replace `YOUR_USERNAME` with your actual username. The path must point to where Glances is installed by pipx. ``` [Unit] Description=Glances in web server mode After=network.target [Service] Type=simple ExecStart=/home/YOUR_USERNAME/.local/bin/glances -w Restart=on-failure RestartSec=5s [Install] WantedBy=multi-user.target ``` ### Step 3: Enable and Start the Service After creating and saving the service file, enable and start it: ``` sudo systemctl daemon-reload sudo systemctl enable glances.service sudo systemctl start glances.service ``` ### Step 4: Verify the Service Status Check that the service is running correctly: ``` sudo systemctl status glances.service ``` You should see `Active: active (running)` if everything is working properly. ## Troubleshooting ### Common Issues #### Error 217/USER If you see an error like: ``` Active: activating (auto-restart) (Result: exit-code) Process: XXXX ExecStart=/home/username/.local/bin/glances -w (code=exited, status=217/USER) ``` This indicates an issue with the User directive. The solution is to remove the User line from the service configuration. #### Service Won't Start Check the detailed logs to identify the issue: ```bash journalctl -u glances.service ``` #### Wrong Path to Glances If you installed Glances in a different location, update the path in the ExecStart line accordingly. ## Accessing Glances Web Interface Once the service is running, you can access the Glances web interface by opening a browser and navigating to: ``` http://localhost:61208 ``` Or replace `localhost` with your server's IP address to access it from other devices on your network: ``` http://YOUR_SERVER_IP:61208 ``` ## Advanced Configuration ### Custom Port To run Glances on a different port, modify the ExecStart line in the service file: ``` ExecStart=/home/YOUR_USERNAME/.local/bin/glances -w --port 8080 ``` ### Additional Arguments You can add any valid Glances command-line arguments to the ExecStart line: ``` ExecStart=/home/YOUR_USERNAME/.local/bin/glances -w --disable-plugin docker --time 2 ``` Common arguments: - `--time 2`: Update frequency in seconds - `--disable-plugin NAME`: Disable a specific plugin - `--disable-webui`: Disable the web UI but keep the web server ## Maintenance ### Stopping the Service ```bash sudo systemctl stop glances.service ``` ### Disabling the Service To prevent Glances from starting on boot: ```bash sudo systemctl disable glances.service ``` ### Viewing Logs ```bash journalctl -u glances.service ``` ### Restarting After Configuration Changes After modifying the service file: ```bash sudo systemctl daemon-reload sudo systemctl restart glances.service ``` ## References - [Glances Official Documentation](https://glances.readthedocs.io/en/latest/) - [Systemd Service Documentation](https://www.freedesktop.org/software/systemd/man/systemd.service.html) --- _Last updated: May 1, 2025_