2

I am suffering from occasional desktop freezes and am still investigating the cause. (Links forthcoming.) In the meantime I came across the following suggestion to cpulimit the unity-panel-service, which is working great so far!

sudo cpulimit -eb unity-panel-service -l 30

I would now like to configure cpulimit so that it:

  • starts as soon as I log in
  • runs in the background (no terminal required)
  • if unity-panel-service restarts, it should discover and limit the new process

Is this possible?

Note: I am aware that this is a workaround to a desktop bug. My question is primarily about using cpulimit, rather than the bug/workaround. When I have a moment I will provide links relating to the bug itself so discussion on that front can happen elsewhere.

lofidevops
  • 20,924

1 Answers1

0

How to run a command at login?:

Adding the command to the end of ~/.profile should do the trick (where ~ represents your home directory).

..you can start a script from a .desktop file in ~/.config/autostart/

OPTIONS -b --background run in background

sudo cpulimit -l 30 -b -p $(pgrep -o "unity-panel-service")

If you put a single & at the end of the command on a cli, it's supposed to run the job in the background. And it should find the new pid from the name every time. You can check if its running by:

pgrep -o "cpulimit"

Or create a bash script from it and make the script executable and set it to auto-run using autostart in Ubuntu.

alchemy
  • 762