How to find the age of a Linux process

To find out the age for any running process, you can use the following command:

#ps aux
……………..
nagios    1206  0.0  0.0  41184   584 ?        Ss   Mar11   2:28 /usr/sbin/nrpe
root      1227  0.0  0.0   7392   564 ?        Ss   Mar11   0:59 /usr/sbin/vnsta
root      1320  0.0  0.0      0     0 ?        S    Mar11   0:18 [flush-202:0]
root      1439  0.0  0.5 105616  5416 ?        Ss   Mar11   0:46 /usr/sbin/apach
root      1474  0.0  0.0  12744   492 hvc0     Ss+  Mar11   0:00 /sbin/getty -L
root      1476  0.0  0.0  14500   504 tty1     Ss+  Mar11   0:00 /sbin/getty -8
www-data  5295  0.0  0.7 121964  7584 ?        S    11:49   0:00 /usr/sbin/apach
root      5353  0.0  0.4  91168  4676 ?        Ss   11:50   0:00 sshd: root@nott
root      5539  0.0  0.0  12768   936 ?        Ss   11:50   0:00 /usr/lib/openss
root      5542  0.0  0.4  91168  4672 ?        Rs   11:50   0:00 sshd: root@pts/
root      5675  0.0  0.4  21624  4212 pts/0    Ss   11:50   0:00 -bash
backuppc  5838  0.1  2.8  84612 29260 ?        S    11:52   0:06 /usr/bin/perl /
backuppc  5841  0.0  0.0      0     0 ?        Z    11:52   0:00 [ssh] <defunct>
……………………….


In the above example, you can only see that process 1206 has been running since Mar 11, but there is no indication of the time it was started.
But the below command can give you more appropriate answer:
stat /proc/<pid> 

For example, here's an exact time-stamp for process 1206, which "ps" command shows only as Mar 11:
# stat /proc/1206

File: `/proc/1206'
  Size: 0               Blocks: 0          IO Block: 1024   directory
Device: 3h/3d   Inode: 10025       Links: 8
Access: (0555/dr-xr-xr-x)  Uid: (  113/  nagios)   Gid: (  121/  nagios)
Access: 2014-03-11 17:25:59.864000001 +0530
Modify: 2014-03-11 17:25:59.864000001 +0530
Change: 2014-03-11 17:25:59.864000001 +0530

 Birth: -

No comments:

Post a Comment