[Linux] プロセスの起動日時を調べる方法

Linux

プロセスが起動された日時は、psコマンドで調べることができます。 しかひ、通常のフォーマット (ps -efps auxなど)では、プロセスの起動が24時間を超えると時間が表示されなくなります。
この場合、psコマンドの-oオプションでlstartを指定することで、起動日時を表示させることができます。

スポンサーリンク

通常フォーマットの例

$ ps -ef | head -5
UID          PID    PPID  C STIME TTY          TIME CMD
root           1       0  0 Oct28 ?        00:00:02 /usr/lib/systemd/systemd --switched-root --system --deserialize 18
root           2       0  0 Oct28 ?        00:00:00 [kthreadd]
root           3       2  0 Oct28 ?        00:00:00 [rcu_gp]
root           4       2  0 Oct28 ?        00:00:00 [rcu_par_gp]

フォーマットにlstartを指定した例

$ ps -eo user,pid,ppid,c,lstart,tty,time,cmd | head -5
USER         PID    PPID  C                  STARTED TT           TIME CMD
root           1       0  0 Thu Oct 28 20:39:15 2021 ?        00:00:02 /usr/lib/systemd/systemd --switched-root --system --deserialize 18
root           2       0  0 Thu Oct 28 20:39:15 2021 ?        00:00:00 [kthreadd]
root           3       2  0 Thu Oct 28 20:39:15 2021 ?        00:00:00 [rcu_gp]
root           4       2  0 Thu Oct 28 20:39:15 2021 ?        00:00:00 [rcu_par_gp]

以上、プロセスを起動した日時を調べる方法の紹介でした。

タイトルとURLをコピーしました