nice命令
进程的 nice 值,可以通过 nice 命令和 renice 命令修改,进而调整进程的运行顺序。
nice 命令可以给要启动的进程赋予 NI 值,但是不能修改已运行进程的 NI 值。
nice 命令格式
[root@localhost ~] # nice [-n NI值] 命令
-n NI值:给命令赋予 NI 值,该值的范围为 -20~19;
例如:
[root@localhost ~]# service httpd start
[root@localhost ~]# ps -le 丨 grep "httd" | grep -v grep
F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD
1 S 0 2084 1 0 80 0 - 1130 - ? 00:00:00 httpd
5 S 2 2085 2084 0 80 0 - 1130 - ? 00:00:00 httpd
5 S 2 2086 2084 0 80 0 - 1130 - ? 00:00:00 httpd
5 S 2 2087 2084 0 80 0 - 1130 - ? 00:00:00 httpd
5 S 2 2088 2084 0 80 0 - 1130 - ? 00:00:00 httpd
5 S 2 2089 2084 0 80 0 - 1130 - ? 00:00:00 httpd
#用默认优先级自动apache服务,PRI值是80,而NI值是0
[root@localhost ~]# service httpd stop
#停止apache服务
[root@localhost ~]# nice -n -5 service httpd start
#启动apache服务,同时修改apache服务进程的NI值为-5
[rooteiocdlhost ~]# ps -le | grep "httpd" | grep -v grep
F S UID PID PPID C FRI NI ADDR SZ WCHAN TTY TIME CMD
1 S 0 2122 1 0 75 5 - 1130 - ? 00:00:00 httpd
5 S 2 2123 2122 0 75 5 - 1130 - ? 00:00:00 httpd
5 S 2 2124 2122 0 75 5 - 1130 - ? 00:00:00 httpd
5 S 2 2125 2122 0 75 5 - 1130 - ? 00:00:00 httpd
5 S 2 2126 2122 0 75 5 - 1130 - ? 00:00:00 httpd
5 S 2 2127 2122 0 75 5 - 1130 - ? 00:00:00 httpd
#httpd进程的PRI值变为了75,而NI值为-5