Getting Glances to run on reboot on RasPi

I’m sure I’m missing something obvious here since I’m new to Raspian but I cannot get Glances to run unless I open a Putty session and manual start it. It works, but of course it will die if I close the session.

I tried setting it up in crontab as the Pi user and even as the root and while both entries exist, neither one seems to start it up. I have it in like this:

@reboot glances -w    

Any idea what I am doing wrong?

I have had issues with network enabled programs starting on boot. A couple of things that might help:

  1. Got to raspi-config and pick the “Wait for Network at Boot” option - sometimes, especially if you are using DHCP, the network doesn’t come up right away. Using systemd, things tend to boot a lot quicker so this can be an issue. Selecting wait at boot might do the trick.

  2. Write a simple script to call glances and put sleep 10 at the top to delay the startup.

I have solved similar issues with both of these techniques.

Good Luck!

Thanks for the advice; I’ll make those changes later and let you know if it solves the issue

But does my crontab entry look correct though? And which user should I create the entry under or does it even matter? (I’m assuming it’s OK or you would have mentioned it but just want to be sure.)

It looks OK to me - I’ll take a look at this as well because it would be cool to get glances running on all my PIs :slight_smile: I’ll let you know when I find a working combination.

Wouldn’t it be easier to use a systemd service unit? Like (untested):

[Unit]
Description=Glances daemon
After=network.target

[Service]
ExecStart=/usr/bin/glances -w

[Install]
WantedBy=multi-user.target
1 Like

I took a similar approach and got it working just now, I used a startup script I found here

Grab the script and set it up as he describes, make sure it is executable:

$ sudo chmod +x /etc/init.d/glances

check it works:

$ sudo /etc/init.d/glances start

If all is well enable it for start on reboot:

$ sudo systemctl enable glances
Synchronizing state for glances.service with sysvinit using update-rc.d...
Executing /usr/sbin/update-rc.d glances defaults
Executing /usr/sbin/update-rc.d glances enable

Works great for me! I couldn’t get it to work anyway using cron.

4 Likes

That worked fantastic, Andrew! Thank you very much for your help.

I pushed the script with WinSCP and then used that to edit it as directed in the source, then used WinSCP to modify the perms. The rest I did as you directed. (Just wanted to add this in case someone wanted another way to do it in a GUI).

Thanks again!

1 Like

Anyone else who comes here in the future… please see