Search code examples
linuxshellps

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


Solution

  • 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.