Linux command
cpulimit 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Limit a process by PID to 25% CPU
cpulimit -p [1234] -l [25]
Limit by executable name
cpulimit -e [program] -l [25]
Launch a program with 50% CPU limit
cpulimit -l [50] -- [program] [arg1] [arg2]
Run cpulimit in background
cpulimit -l [50] -b -- [program]
Also throttle child processes
cpulimit -l [25] -m -- [program]
Limit on a multicore system
cpulimit -p [1234] -l [200]
说明
cpulimit limits the CPU usage of a process by sending SIGSTOP and SIGCONT signals to throttle CPU consumption. It can target running processes or launch new ones with CPU limits applied.
参数
- -p, --pid=N
- Target process by PID
- -e, --exe=FILE
- Target process by executable name
- -P, --path=PATH
- Target process by absolute path to executable
- -l, --limit=N
- CPU percentage limit (mandatory). 1-100 per core; on multicore systems, values above 100 are allowed (e.g., 200 for 2 cores).
- -b, --background
- Run cpulimit as a background process
- -f, --foreground
- Run in foreground while waiting for launched process
- -c, --cpu=N
- Specify number of CPU cores (for percentage calculation)
- -k, --kill
- Kill process instead of throttling if over limit
- -m, --monitor-forks
- Also watch and throttle child processes
- -r, --restore
- Restore a process previously killed with -k
- -q, --quiet
- Suppress output messages
- -v, --verbose
- Display control statistics
- -z, --lazy
- Exit if target process is absent or terminates
FAQ
What is the cpulimit command used for?
cpulimit limits the CPU usage of a process by sending SIGSTOP and SIGCONT signals to throttle CPU consumption. It can target running processes or launch new ones with CPU limits applied.
How do I run a basic cpulimit example?
Run `cpulimit -p [1234] -l [25]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -p, --pid=N do in cpulimit?
Target process by PID