EmbLogic's Blog

ABOUT “NICE” THIS IS USEFUL FOR :IPC

Most people don’t even know that running processes at a different priority is an option.  Many have never even heard of the nice command.  In this article, I will discuss what thenice command can do for your processes.

Every process needs some time on the CPU regardless of its priority.  Some get more time or run more often frequently because of their priority. Some are elevated in priority until their turn comes around.

A newly initiated process acquires the priority of it’s parent.  For example,  If you use the lscommand after you log in, the ls process will inherit the priority of your shell. By using the nicecommand, you can lower the priority of a process.  On some systems, the kernel will itself automatically boost the priority of a process when it has been waiting for a long time
without being run.

The range of values that the nice command use depends on the particular Unix system.  Typically, values will run between  -20 and +19, but only root can increase the priority of a process above its default.

There are two options to reduce/increase value of a process.  You can either do it using thenice command or the renice command.

To reduce a value of your shell you can do:

$ nice -10 mysqld

The -10 command lowers the priority of a process ten notches.  You also can run this:

$ renice +19 PID

The +19 bumps the priority of a running process to 19.

To learn more about nice, simply type ‘man nice’ and ‘man renice’ on your Unix system and get a better idea of what all the options it has.  While nicing our processes maybe an old style sysadmin work, it can become very useful when systems get busy.  You can have some processes take priority over others and have them complete their task faster

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>