NAME
run-stop-run - limit CPU usage of processes
SYNOPSIS
run-stop-run [options] command [arguments]
run-stop-run [options] -p PID1,-PGID
DESCRIPTION
This program controls the CPU usage of processes by repeatedly sending SIGSTOP and SIGCONT signals. It can be used to run a command or on the PIDs of already-running processes.
It is useful in the case that you have a long-running CPU-intensive process and want to maintain a thermal limit (think fanless computer). Or you may have a program that uses all cores without providing a means to configure the level of concurrency.
OPTIONS
- -v, --verbose
-
Be verbose.
- -n, --dry-run
-
Don't send any signals, just print the command (if given), or list the PIDs/PGIDs it would affect.
- -l, --limit PERCENT
-
The percent of time to run. The default value is 50.0; possible values are 1..99. Specify this with only one of --run or --stop. The other will be derived.
- -r, --run SECONDS
-
The number of seconds to run. The default value is 1.0. Specify this with only one of --limit or --stop. The other will be derived.
- -s, --stop SECONDS
-
The number of seconds to stop. Specify this with only one of --limit or --run. The other will be derived.
- -p, --pid PID,-PGID
-
A list of PIDs of already-running processes. The list may be comma-separated or the option given multiple times. If the PID is negative, it is interpreted as a process group.
- -g, --group
-
Operate on the entire process groups. This is the default when launching a command, as it will start a new process group.
- -c, --children
-
Operate on all descendent processes of the command or PIDs. These are found by scanning the process table and checking the parent process and group of each process. Note that it's not always possible to determine the parentage, since the process might have double-forked and changed it's process group.
- -V, --version
-
Display the version.
- -h, --help
-
Display the help message.
- -H, --man
-
Display this documentation.
KNOWN PROBLEMS
Operating on a PID of a foreground process will likely result in job control message from the shell indicating the job was stopped when it receives the SIGSTOP signal. Note that the job will be continued in the background after receiving the SIGCONT signal, but no shell message will be displayed.
It is not always possible to determine if a process is a child process. In that case, you can run the command separately and then run this program against a list of PIDs.
SEE ALSO
https://github.com/opsengine/cpulimit
https://en.wikipedia.org/wiki/Cgroups
https://www.freedesktop.org/software/systemd/man/systemd.resource-control.html
COPYRIGHT AND LICENSE
Copyright (c) 2022 gray <gray at cpan.org>
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
AUTHOR
gray, <gray at cpan.org>