您的位置:首页 > 其它

ps -aux的错误用法

2012-11-21 10:37 405 查看
很多人一直在使用ps -aux,其实这种用法是错误的,应该使用ps aux和ps -fe。man ps的第一页有一段话:

Note that "ps -aux" is distinct from "ps aux". The POSIX and UNIX standards require that "ps -aux" print all processes owned by a user named "x", as well as printing all processes that would be selected by the -a option. If the user named "x" does not exist,
this ps may interpret the command as "ps aux" instead and print a warning. This behavior is intended to aid in transitioning old scripts and habits. It is fragile, subject to change, and thus should not be relied upon.

翻译如下

请注意"ps -aux"不同于"ps aux"。POSIX和UNIX的标准要求"ps -aux"打印用户名为"x"的用户的所有进程,以及打印所有将由-a选项选择的过程。如果用户名为"x"不存在,ps的将会解释为"ps aux",而且会打印一个警告。这种行为是为了帮助转换旧脚本和习惯。它是脆弱的,即将更改,因此不应依赖。

如果你运行ps -aux >/dev/null,那么你就会得到下面这行警告信息

Warning: bad ps syntax, perhaps a bogus '-'? See http://procps.sf.net/faq.html
如果你在cygwin上运行ps -aux,那么你会得到下面的警告信息

ps: user x unknown

转自:http://walkerxk.i.sohu.com/blog/view/150633165.htm
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: