Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
302 views
in Technique[技术] by (71.8m points)

linux - How to get year also in the startup process when doing ps -ef

I am doing ps -ef | grep process.

I am getting an output in this format:

17297     1 12 Jan10 ?        02:53:26 /usr/java/jdk1.8.0_221-amd64/bin/java

Here instead of Jan10, I want Jan10 2021


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Use the formatted output (-o option) of ps command and choose the format. For example:

$ ps -eo pid,ppid,lstart,cmd
    PID    PPID                  STARTED COMMAND
      1       0 Mon Jan 11 12:26:03 2021 systemd
      2       0 Mon Jan 11 12:26:03 2021 kthreadd
      3       2 Mon Jan 11 12:26:03 2021 rcu_gp
      4       2 Mon Jan 11 12:26:03 2021 rcu_par_gp
      5       2 Mon Jan 11 12:26:03 2021 kworker/0:0-events
      6       2 Mon Jan 11 12:26:03 2021 kworker/0:0H-kblockd
      9       2 Mon Jan 11 12:26:03 2021 mm_percpu_wq
[...]

Available formats are described in the "STANDARD FORMAT SPECIFIERS" section of the manual.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...