在 unix 中更改 ps 时间的时间格式

change time format for ps time in unix

我正在尝试以 hh:mm 格式取回时间,不带秒数, 运行 这个:

 ps -p $pid -o time=

返回(例如00:03:19但我只想(例如00:03

我试过查看手册并在网上搜索,找不到任何我能理解的内容。有谁可以帮助我吗。提前致谢。

ps 本身不提供配置时间格式。但是,您可以通过管道传输到 cut:

ps -p $pid -o time= | cut -d: -f1,2