PSコマンドでプロセスの起動時刻を調べる

2024-02-15

PSコマンドでプロセスの起動時間を確認する方法

プロセスの起動時間を確認しようと「ps -ef」,「ps aux」で確認しても起動時間は表示されません
※ grep -v grepのオプションは、grepコマンドの実行結果を除外しています

$ ps -ef|grep httpd | grep -v grep
root 638 1 0 05:00 ? 00:00:02 /usr/sbin/httpd -DFOREGROUND
apache 3718 638 0 15:18 ? 00:00:01 /usr/sbin/httpd -DFOREGROUND
apache 3734 638 0 15:23 ? 00:00:02 /usr/sbin/httpd -DFOREGROUND
apache 3736 638 0 15:23 ? 00:00:01 /usr/sbin/httpd -DFOREGROUND
apache 3801 638 0 15:38 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 3802 638 0 15:38 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND

$ ps aux|grep httpd | grep -v grep
root 638 0.0 1.5 447240 16296 ? Ss 05:00 0:02 /usr/sbin/httpd -DFOREGROUND
apache 3718 0.2 4.2 489296 44956 ? S 15:18 0:03 /usr/sbin/httpd -DFOREGROUND
apache 3736 0.4 4.1 488080 43884 ? S 15:23 0:05 /usr/sbin/httpd -DFOREGROUND
apache 3801 0.3 3.6 482288 37884 ? S 15:38 0:01 /usr/sbin/httpd -DFOREGROUND
apache 3845 0.1 1.4 450348 15292 ? S 15:40 0:00 /usr/sbin/httpd -DFOREGROUND
apache 3869 1.1 4.2 488848 44296 ? S 15:41 0:01 /usr/sbin/httpd -DFOREGROUND

ps -eo lstart,pid,args | grep (プロセス名) で起動時間が確認できます

  • -e:全てのプロセスを選択する。-A と等しい。
  • -o:ユーザー定義フォーマット。
  • lstart:コマンドが起動された時刻。
  • pid:プロセスのプロセス ID 番号。
  • args:文字列の引き数がついたコマンド

オプションの詳細:Man page of PS

$ ps -eo lstart,pid,args | grep httpd | grep -v grep
Tue Jul 7 05:00:01 2015 638 /usr/sbin/httpd -DFOREGROUND
Tue Jul 7 15:18:56 2015 3718 /usr/sbin/httpd -DFOREGROUND
Tue Jul 7 15:23:28 2015 3736 /usr/sbin/httpd -DFOREGROUND
Tue Jul 7 15:38:49 2015 3801 /usr/sbin/httpd -DFOREGROUND
Tue Jul 7 15:40:20 2015 3845 /usr/sbin/httpd -DFOREGROUND
Tue Jul 7 15:41:27 2015 3869 /usr/sbin/httpd -DFOREGROUND

スポンサーリンク

0
0