EggXpert

The official Newegg tech support community and Newegg tech support forums. Learn about PC building, case mods, computer repairs, and computer troubleshooting. Get help from knowledgable community members about computer hardware and computer software, laptops, notebooks, netbooks, consumer electronics & mp3 players, home networking, lcd TVs, home audio and more.
Welcome to eggXpert.com. Sign in | Join | Help
in Search
Advanced Search

Runbook: Linux.Reprioriting Processes

Last post 09-04-2009, 11:17 PM by root. 2 replies.
Sort Posts: Previous Next
  •  09-03-2009, 12:22 AM 565514

    Runbook: Linux.Reprioriting Processes

    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.
  •  09-04-2009, 6:07 AM 565821 in reply to 565514

    Re: Runbook: Linux.Reprioriting Processes

    Hey Root, your Linux-Fu is very strong now...

    In a side-note,  I was working on getting a 64-bit compiled version of zsnes with 64-bit libao. After I did the compile and had it working, I was clearing out the source code folder and tarball right before I went to bed, but due to lack of sleep, I accidentally put a space where it shouldn't be...

    rm -r zsnes *

    In my home directory and in like half a second it nukes my entire home folder except for the hidden files..  Frustrated   Thank god for backups & rsync.. But I got even less sleep last night than usuaul..

     

     I think what I should work on are like Anti-Runbooks or things that you should *not* do when running Linux.. Have to be careful with those darn wildcards..


    Onboard RAID vs. 3Ware RAID

    I never recommend people run RAID-5 with onboard chipsets.
  •  09-04-2009, 11:17 PM 566229 in reply to 565821

    Re: Runbook: Linux.Reprioriting Processes

    Haha, I think we've all done that atleast once. I know I accidently did "rm -rf *" and didn't realize I was in the / directory.

    It's always the stupid stuff that kills us.

     

     


    "Oh Gravity, Thou Art A Heartless b***h"

    -Sheldon

    Click to read my stories.
View as RSS news feed in XML

 Home   Forums   Chat   Blogs   Deals   Newsletter   About 

 FAQ   Terms of Use   Privacy Policy   Contact Us 

©2009 Newegg, Inc. All rights reserved.