• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

renice Command Examples in Linux

by admin

When we work with the nice command, it’s clear that it can’t change the scheduling priority of running processes. As we’ve just seen, we would need to stop and then start the process in this case. This is where the renice command shines. We can leverage the renice command to change the niceness while the process is running. To see the syntax, we would pass the –help option:

# renice --help
Usage:
 renice [-n]  [-p|--pid] ...
renice [-n]   -g|--pgrp ...
 renice [-n]   -u|--user ...
Alter the priority of running processes.
Options:
 -n, --priority    specify the nice increment value
 -p, --pid          interpret argument as process ID (default)
 -g, --pgrp         interpret argument as process group ID
 -u, --user | interpret argument as username or user ID
 -h, --help     display this help and exit
 -V, --version  output version information and exit

renice command may be applied to a process, process group, or user (target). A privileged user may alter the priority of other users’ processes. priority must, for ordinary users, lie between 0 and the environment variable PRIO_MAX (normally 20), with a higher number indicating increased niceness. A higher niceness value means that the process will run at a lower priority. A privileged user may set a negative priority, as low as PRIO_MIN (normally −20), to speed up processes. See the nice command for setting the scheduling priority for processes when they are initially run.

renice Command Examples

1. To set the priority for process:

# renice -n 20 -p 2112
# renice --priority 20 -p 2112 

2. To change the priority for process os a group:

# renice -n 20 -g SUPPORT 

3. To change the priority for process os a user:

# renice -n 20 u mike 

4. To get the version:

# renice -v
# renice --version 

5. To get the help:

# renice -h
# renice --help 

6. Change priority of all processes owned by a user:

# renice -n niceness_value -u user

7. Change priority of all processes that belong to a process group:

# renice -n niceness_value --pgrp process_group

Conclusion

The renice command is used to change the nice level of an existing process. Its syntax is as follows:

$ renice -n [NICELEVEL] [PID’s]

Apart from the renice command, the top command can also be used to modify the nice value of a running process. The following steps are used to modify a process priority using the top command:

  • Invoke the top command.
  • Press r key on the keyboard to bring up the option for specifying a new nice value on the top command’s current interactive session.
  • Enter the new nice value and PID, followed by pressing the Enter key.

Filed Under: Linux

Some more articles you might also be interested in …

  1. jarsigner: command not found
  2. Issue Opening a Firewalld Port in CentOS/RHEL 8
  3. kexec: command not found
  4. CentOS / RHEL : How to Disable and Blacklist Linux Kernel Module to prevent it from loading automatically
  5. dconf : command not found
  6. colrm Command Examples in Linux
  7. CentOS / RHEL : How to configure an DHCP server
  8. ipcs Command Examples in Linux
  9. What is HBA Queue Depth and How to Check the Current Queue Depth Value and how to Change it
  10. hdiutil Command Examples in Mac

You May Also Like

Primary Sidebar

Recent Posts

  • qm Command Examples in Linux
  • qm wait Command Examples in Linux
  • qm start Command Examples in Linux
  • qm snapshot Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright