If you wish to run a command which typically uses a lot of CPU (for example, running tar on a large file), then you probably don’t want to bog down your whole system with it. Linux systems provide the nice command to control your process priority at runtime, or renice to change the priority of an already running process. The full manpage has help, but the command if very easy to use:
$ nice -n prioritylevel /command/to/run
The priority level runs from -20 (top priority) to 19 (lowest). For example, to run tar and gzip at a the lowest priority level:
$ nice -n 19 tar -czvf file.tar.gz bigfiletocompress
similarly, if you have a process running, use ps to find the process ID, and then use renice to change it’s priority level:
$ renice -n 19 -p 987 32
This would change processes 987 and 32 to priority level 19.
1 comment
Comments are closed.