I have a raspberry pi which stays on for extended period of time. To avoid it from crashing, I have a cron job that periodically checks for top memory consuming apps and then restarts them as needed. The shell script monitors the services correctly but for some reason doesn't restart lxpanel correctly. The shell script runs as sudo and uses the following to restart the lxpanel service:
sudo -u mimo lxpanelctl restart
, where mimo is my username
I do not see a drop in memory usage, so it doesn't seem that the command successfully restarts lxpanel. Whereas if I run lxpanelctl restart
from a terminal instance, I do see the required/expected drop in lxpanel's memory usage.
So now the question is how can I run lxpanelctl restart from within the script.
I've tried:
lxpanelctl restart
, which when invoked from the script running as sudo, kills the desktop session and requires a reloginsudo -u mimo lxpanelctl restart
doesn't appear to actually restart the panel as I do not see a drop in mem usage.runuser -l mimo -c 'lxpanelctl restart'
doesn't appear to actually restart the panel as I do not see a drop in mem usage.