Run unrar on Specific CPU Cores with taskset
This article explains how to restrict the unrar utility
to specific CPU cores using the Linux taskset command. It
covers the core syntax for setting CPU affinity at execution time,
examples for targeting individual or multiple cores, methods for
modifying already running processes, and the practical benefits of
controlling CPU usage during resource-heavy decompression tasks.
Yes, You Can Use taskset with unrar
The taskset utility sets or retrieves the CPU affinity
of a process in Linux. Because unrar runs as a standard
userspace process, you can launch it through taskset to
restrict its execution to one or more designated processor cores. This
is useful for preventing large or multi-part archive extractions from
consuming all available computing resources on a server or
workstation.
Basic Syntax
To launch unrar bound to specific CPU cores, use the
-c (or --cpu-list) flag with
taskset, followed by a comma-separated list or range of
core identifiers, and then your standard unrar command:
taskset -c <core-list> unrar <command> <archive.rar> [destination]CPU cores are numbered starting from 0. For example, on
a 4-core machine, the cores are 0, 1,
2, and 3.
Practical Examples
Restrict unrar to a Single Core
To run an extraction restricted entirely to CPU Core 0:
taskset -c 0 unrar x archive.rarThis isolates the workload so the remaining cores remain entirely free for other system tasks.
Restrict unrar to a Specific List of Cores
To bind unrar to use only Core 1 and Core 3:
taskset -c 1,3 unrar x archive.rar /path/to/destination/Restrict unrar to a Range of Cores
To bind unrar across a range of cores, such as Cores 2
through 5:
taskset -c 2-5 unrar e archive.rarAssigning Cores to an Already Running unrar Process
If an unrar process is already executing, you can change
its CPU affinity dynamically using the process ID (PID) and the
-p flag:
- Locate the PID of the process:
pgrep unrar - Apply the desired CPU cores to that PID:
taskset -cp 0,1 <PID>
Key Considerations
- Threading Behavior: While older versions of
unrarare largely single-threaded, newer versions and custom builds may spawn multiple threads.tasksetwill restrict all child threads created byunrarto the specified core mask. - Permissions: Standard user privileges are
sufficient to assign core affinity to your own
unrarcommands. Modifying the affinity of processes owned by other users requiressudoor root privileges. - I/O Bottlenecks: Restricting CPU cores reduces CPU
contention, but archive decompression is frequently disk I/O intensive.
If system performance remains slow, consider pairing
tasksetwithioniceto limit disk priority alongside CPU affinity.