Wednesday 29 February 2012

How to set a process Priority in Linux

Change the priority of a running process with nice and renice. Negative numbers have a higher priority, the lowest is -20 and "nice" have a positive value.

 # renice -5 586   ------ stronger priority

 Start the process with a defined priority with nice. Positive is "nice" or weak, negative is strong scheduling priority.

# nice -n -5 top   # Stronger priority (/usr/bin/nice)

# nice -n 5 top      # Weaker priority (/usr/bin/nice)
# nice +5 top

While nice changes the CPU scheduler, an other useful command ionice will schedule the disk IO. This is very useful for intensive IO application.


# ionice c3 -p123 # set idle class for pid 123

# ionice -c2 -n0 firefox # Run firefox with best effort and
                                             high priority
# ionice -c3 -p$$ # Set the actual shell to idle priority

nohup

Use nohup to start a process which has to keep running when the shell is closed

# nohup  sh run.sh  -b 0.0.0.0 &
# nohup ping -i 60 > ping.log &

 

 

 
















No comments:

Post a Comment