Any Linux GURU's can help me with a problem starting a service?

Hi

Not directly related to Vera, but I am using the Glances hardware monitoring software on my Raspberry Pi, however the instructions given for creating a startup service are not working and I can’t see why not.

If any Linux Guru wants to take a look please see here.

Thanks.

What’s the output of

sudo systemctl status glances.service

as soon as you start the service daemon

Hi

I ran these commands in terminal:

pi@raspberrypi:~ $ sudo systemctl --system daemon-reload
pi@raspberrypi:~ $ sudo systemctl start glances.service
pi@raspberrypi:~ $ sudo systemctl status glances.service
 glances.service - Glances
   Loaded: loaded (/etc/systemd/system/glances.service; enabled; vendor preset: enabled)
   Active: activating (auto-restart) (Result: exit-code) since Wed 2020-09-23 18:21:38 BST; 3s ago
  Process: 32064 ExecStart=/usr/local/bin/glances --quiet --export influxdb (code=exited, status=2)
 Main PID: 32064 (code=exited, status=2)

If I just run this command in terminal it works and starts sending data to the InfluxDB OK.

glances --quiet --export influxdb

However when I follow their instructions for using that same command in a glances.service startup file it doesn’t load.

Best option is to use screen to run your commands. Search for it.

exit code 2 typically means that you have a permissions problem. Make sure that the access permissions are set properly on the glances directory, subdirectories and files in order to run as a system service.

I set the permissions to 0755 but I’ll double check

Assuming that your ExecStart is correct have you tried Restart=always just to further troubleshoot the issue.

Also does your service need to be up running before any other services on boot.

Hey @peterxbmc

Yes it needs to be running after the InfluxDB.

But they added a line of code for that.

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

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

[Install]
WantedBy=multi-user.target

You need to add the Sleep command in your service daemon before your ExecStart command with ExecStartPre

ExecStartPre=/bin/sleep 30

I think I’ve fixed it. I added the line:

User=pi

in to the glances.service file.

It appears to be loading now after a reboot, fingers crossed it remains that way.

Thanks.

Permissions as suggested above was your issue so. Also careful when constructing service daemons too. They can yield strange results if not carefully scripted.

1 Like

The only other service I created on the Pi was for the Java HA Bridge software, which I use to integrate Vera with Logitech Harmony remotes and their “Home Control” buttons.

I didn’t have any issues setting that service up and it worked first time.

Node-Red I think created its own startup service, I don’t recall creating it myself.

Thanks.