The problem
In last week's post, I discussed using
cpulimit
on multiple processes in the special case of
web browsers, but I wanted a more general solution.
The solution
cpulimit-all.sh
is a wrapper around cpulimit
which will call cpulimit
many times to cover multiple processes of
the same name and subprocesses.
Using that script, the follow is the equivalent of the script from last week to limit all browser processes to 10% CPU:
cpulimit-all.sh --limit=10 --max-depth=1 \
-e firefox -e firefox-esr -e chromium -e chrome
But also, we can add a couple options to include any grandchild processes and check for new processes to limit every minute:
cpulimit-all.sh --limit=10 --max-depth=2 \
-e firefox -e firefox-esr -e chromium -e chrome \
--watch-interval=1m