Search code examples
linuxunixps

change time format for ps time in unix


I am trying to get back the time in the format hh:mm without the seconds, running this:

 ps -p $pid -o time=

gets back (for example) 00:03:19 but I want just (for example) 00:03

I have tried looking at the manual and searched on the net, couldn't find anything that i can understand. Can someone help me please. Thanks in advance.


Solution

  • ps itself doesn't offer to configure the time format. However, you can pipe to cut:

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