网上查了很多都说得模棱两可。
结合http://blog.csdn.net/thinkerabc/article/details/656236,然后自己实践了一下,记一下
1.进入tty,直接nice一下:
ubuntu14043@ubuntu14043:~$ ps -l
F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD
0 S 1000 2079 2078 0 80 0 - 6712 wait pts/5 00:00:00 bash
0 R 1000 2123 2079 0 80 0 - 3554 - pts/5 00:00:00 ps
ubuntu14043@ubuntu14043:~$ nice
0
ubuntu14043@ubuntu14043:~$ ps -l
F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD
0 S 1000 2079 2078 0 80 0 - 6712 wait pts/5 00:00:00 bash
0 R 1000 2174 2079 0 80 0 - 3554 - pts/5 00:00:00 ps
2.
ubuntu14043@ubuntu14043:~$ nice ps -l
F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD
0 S 1000 2079 2078 0 80 0 - 6712 wait pts/5 00:00:00 bash
0 R 1000 2182 2079 0 90 10 - 3554 - pts/5 00:00:00 ps
ubuntu14043@ubuntu14043:~$ nice
0
猜测不带参数的nice命令依然显示的是bash的NI
3.
ubuntu14043@ubuntu14043:~$ nice bash
ubuntu14043@ubuntu14043:~$ nice
10
ubuntu14043@ubuntu14043:~$ ps -l
F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD
0 S 1000 2079 2078 0 80 0 - 6712 wait pts/5 00:00:00 bash
0 S 1000 2222 2079 0 90 10 - 6718 wait pts/5 00:00:00 bash
0 R 1000 2235 2222 0 90 10 - 3554 - pts/5 00:00:00 ps
进一步猜测不带参数的nice显示的是默认的bash的NI
4.
0 R 1000 2245 2222 0 90 10 - 3554 - pts/5 00:00:00 ps
ubuntu14043@ubuntu14043:~$ kill -9 2222
Killed
ubuntu14043@ubuntu14043:~$ ps -l
F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD
0 S 1000 2079 2078 0 80 0 - 6712 wait pts/5 00:00:00 bash
0 R 1000 2246 2079 0 80 0 - 3554 - pts/5 00:00:00 ps
ubuntu14043@ubuntu14043:~$
ubuntu14043@ubuntu14043:~$ nice
0
干掉了新建的bash进程,然后nice不带参数,结果是10
以上验证了不带参数显示的是默认bash的NI。nice会产生三个结果:改变进程的PRI,改变进程的NI,运行进程