I am looking for the equivalent command to nice
, but for setting process priority and selecting the scheduler to use.
I need to be able to type (or include in a script) something like run-with-scheduler batch a-big-long-command
, or run-with-scheduler round-robin priority 10
to set the process priority and scheduler.
Everywhere I look there are article with titles “how to set a process priority in Linux” but they all write about niceness. As you may know niceness is not priority, and up until recently there was no way to set priority. However more recently there has been extra schedulers added to the Linux kernel. These other schedulers, allow priority, and have different behaviour.
E.g. the batch scheduler does not switch to often, and has lower priority than all other schedulers. This results in the tasks running faster (less switching), but only if there are no higher priority tasks running.
The kde tool ksysguard (graphical process viewer), has the ability to view and set a processes niceness, scheduler and priority. However, I am looking for the name of the command line tool.
How, on the command-line, do I specify the scheduler and priority of a command?
Advertisement
Answer
Use schedtool
.
Install package schedtool: ( on debian/ubuntu/mint etc. run sudo apt-get install schedtool
)
Then you will have a command schedtool
, read the manual: man schedtool
, and read up on the schedulers. Don’t use the real time schedulers unless you really really know what you are doing. (you can’t anyway unless run at elevated capabilities.)
Here are some examples.
schedtool -B -e long-process
schedtool -R -p 1 read-time-process
#don’t do itschedtool -a 0 a-process-to-run-on-cpu-0-only
see also http://manpages.ubuntu.com/manpages/hardy/man8/schedtool.8.html