opsengine/cpulimit
FreeCPU usage limiter for Linux
FreeFree tier
About opsengine/cpulimit
Cpulimit is an open-source tool that limits the CPU usage of a process, expressed as a percentage of CPU time rather than absolute time. It works by sending SIGSTOP and SIGCONT POSIX signals to the target process, dynamically adapting to overall system load. All child processes and threads of the specified process share the same CPU percentage limit. Unlike nice or other scheduling priority adjustments, cpulimit directly controls real CPU usage. Developed by Angelo Marletta, it runs on Linux, macOS, and FreeBSD, and is written in C.
Key Features
Limits CPU usage of a process as a percentage (not CPU time)
Dynamically adapts to overall system load
Uses SIGSTOP and SIGCONT POSIX signals to control usage
Applies CPU limit to all child processes and threads of the target process
Does not alter nice value or other scheduling priorities
Open source under a permissive license (see repository)
Runs on Linux, macOS, and FreeBSD
Lightweight and written in C
Pros & Cons
Pros
- Effectively limits real CPU usage without modifying process priority
- Dynamic adaptation to system load prevents overcorrection
- Works recursively on process children and threads
- Lightweight and platform-portable (Linux, macOS, FreeBSD)
- Open source with active community (1.8k stars on GitHub)
Cons
- Only limits CPU usage, not memory, I/O, or other resources
- Relies on SIGSTOP/SIGCONT signals which may cause brief pauses in process execution
- No graphical user interface; command-line only
- Requires manual build and installation (no package manager by default)
Best For
Controlling batch jobs to prevent excessive CPU consumptionLimiting resource usage of background or non-critical processesEnsuring fair CPU sharing among multiple processes on a serverTesting and development environments where CPU throttling is needed
FAQ
What does Cpulimit do?
Cpulimit limits the CPU usage of a process to a specified percentage, preventing it from using more than that amount of CPU time.
How does Cpulimit work?
It sends SIGSTOP and SIGCONT signals to the target process to pause and resume it, controlling the proportion of time it runs relative to idle time.
On which operating systems can Cpulimit run?
It supports Linux, macOS (OS X), and FreeBSD.
Does Cpulimit affect the nice value or scheduling priority?
No, it directly limits CPU usage without changing the nice value or other scheduling priorities.
Can I limit CPU usage for all threads of a process?
Yes, all child processes and threads of the specified process will share the same CPU percentage limit.