hello
is this script ok or dangerous?
does it kill a task or a browser?
Can I type in line by line into a terminal?
Is it fine to limit CPU of all browsers?
Regards Sophie
The following script will limit the CPU usage of all browser processes
to $LIMIT percent CPU. Note that the limit is per process not total over
all processes, so you may want to set it quite low to actually have an
effect.
LIMIT=10 # Hard-code a limit of 10% CPU as an example.
# Kill child processes (stop limiting CPU) on script exit.
for sig in INT QUIT HUP TERM; do
trap "
pkill -P $$
trap - $sig EXIT
kill -s $sig "'"$$"' "$sig"
done
trap cleanup EXIT
# Find and limit all child processes of all browsers.
for name in firefox firefox-esr chromium chrome
do
for ppid in $(pgrep "$name")
do
cpulimit --pid="$ppid" --limit="$LIMIT" &
for pid in "$ppid" $(pgrep --parent "$ppid")
do
cpulimit --pid="$pid" --limit="$LIMIT" &
done
done
done
Posted by: "highskywhy@yahoo.de" <highskywhy@yahoo.de>
Reply via web post | • | Reply to sender | • | Reply to group | • | Start a New Topic | • | Messages in this topic (90) |
No comments:
Post a Comment