Intro
Some of you might be aware of this, others may not, but you can actually prioritize your applications in an OS. Windows you can do it under Task Manager, and Linux you can use something called 'nice' or 'renice'.
Why?
Why would one want to change the prioritize or an application/script/process/etc? There are a few situations where you want a process to have a lower priority than others. Take for instance you are trans-coding a video (heavy CPU task) but you don't want it to interfere with your web browsing or movie watching when you're on the computer. This can be done by setting the trans-code process to a lower priority than everything else. Meaning, when you are away from you computer (say, sleeping), the trans-coding can take on all the unused CPU process.
How?
Two ways of going about it. You can either start an application/script/etc at a certain level or you can re-prioritize it after you've started it. But before we get into this, let's touch brieflly on nice. There are varing degree's of priority with nice, ranging from -20 to 19. -20 is the highest priority a task can have while 19 is the lowest priority. If that sounds backwards to you, think of the nice number as being "how nice will this play with others?"
Most distros start an application as 0. So how do we change this? Let's say we want to run a script called 'transcode.sh' on the lowest priority, there are two ways about it:
Start it at 19...
nice 19 ./transcode.sh
or change it to 19 after it's been started...
./transcode.sh
ps aux | grep transcode.sh
renice 19 12543
Where 12543 is the process ID found in the 'ps' output (hint: it's right next to the user name).
Now, when you are surfing the net or doing general tasks on the computer, the transcode process will have the lowest priority and it won't hinder your webbrowsing. But when you step away, and you're no longer using the browser, the transcode process will take up all your CPU power.
Footnotes
1. If you nice a process into the negatives, you must have root privileges.
2. If you don't specify a nice value, it defaults to 10.
"Oh Gravity, Thou Art A Heartless b***h"
-Sheldon
Click to read my stories.