[20160816]ps 显示问题.txt
-- 我建立linux的测试机器oracle用户是oracle11g。这样ps -ef显示用户是数字。
$ ps -lef | egrep "UID|ora_" | head -6
F S UID PID PPID C PRI NI ADDR SZ WCHAN STIME TTY TIME CMD
0 S 503 6315 5928 0 80 0 - 25785 pipe_w 09:31 pts/1 00:00:00 egrep UID|ora_
0 S 503 24195 1 0 80 0 - 456683 poll_s Jul08 ? 00:05:44 ora_pmon_testdg
0 S 503 24197 1 0 80 0 - 456122 semtim Jul08 ? 00:01:32 ora_psp0_testdg
0 S 503 24199 1 0 58 - - 456122 hrtime Jul08 ? 01:15:52 ora_vktm_testdg
0 S 503 24203 1 0 80 0 - 456122 semtim Jul08 ? 00:00:01 ora_gen0_testdg
$ id
uid=503(oracle11g) gid=501(oinstall) groups=501(oinstall),502(dba),503(oper)
--实际上UID=503,主要是用户oracle11g,长度大于8个字符。所以ps显示数字。
--参考链接
http://blog.dbi-services.com/list-usernames-instead-of-uids-with-the-ps-command-for-long-usernames/
export PS_FORMAT="user:12,pid,%cpu,%mem,vsz,rss,tty,stat,start,time,command"
$ ps ax | egrep "USER|ora_" | head -5
USER PID %CPU %MEM VSZ RSS TT STAT STARTED TIME COMMAND
oracle11g 6386 0.0 0.0 103140 848 pts/1 S+ 09:36:13 00:00:00 egrep USER|ora_
oracle11g 24195 0.0 0.5 1826732 20484 ? Ss Jul 08 00:05:44 ora_pmon_testdg
oracle11g 24197 0.0 0.4 1824488 16640 ? Ss Jul 08 00:01:32 ora_psp0_testdg
oracle11g 24199 0.1 0.4 1824488 16432 ? Ss Jul 08 01:15:52 ora_vktm_testdg
--不过 ps -lef | egrep "UID|ora_" | head -6 依旧显示503.
--不知道有什么好方法实现显示用户名。