12 Start Glances through Systemd
Nicolas Hennion edited this page 2024-07-07 10:25:49 +02:00

Create unit

Note: if you install Glances with pip and the --user option, you should set the User in the systemd file. Please read https://github.com/nicolargo/glances/issues/2673.

Create a new unit by creating a file called glances.service in the /etc/systemd/system/ folder.

Example: start a Glances server

[Unit]
Description=Glances
After=network.target

[Service]
ExecStart=/usr/local/bin/glances -s
Restart=always
RemainAfterExit=no

[Install]
WantedBy=multi-user.target

Example: start a Glances webserver

[Unit]
Description=Glances
After=network.target

[Service]
ExecStart=/usr/local/bin/glances -w
Restart=always
RemainAfterExit=no

[Install]
WantedBy=multi-user.target

Example: Start a Glances client exporting stats to an InfluxDB server

[Unit]
Description=Glances
After=network.target influxd.service

[Service]
ExecStart=/usr/local/bin/glances --quiet --export influxdb
Restart=always
RemainAfterExit=no
RestartSec=30s
TimeoutSec=30s

[Install]
WantedBy=multi-user.target

Enable unit for automatic start while booting

sudo systemctl enable glances.service

Start the service

sudo systemctl start glances.service

And SeLinux ?

If your system is protected by SeLinux, please read the following tips: https://github.com/nicolargo/glances/issues/2673#issuecomment-2212320260