Parse ps' “etime” output and convert it into seconds

后端 未结 14 2125
难免孤独
难免孤独 2020-12-30 12:43

These are possible output formats for ps h -eo etime

21-18:26:30
   15:28:37
      48:14
      00:01

How to parse them into se

14条回答
  •  遥遥无期
    2020-12-30 12:59

    Think I might be missing the point here but the simplest way of doing this is:

    ps h -eo etimes
    

    Note the 's' on the end of etime.

提交回复
热议问题