![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Check whether ftpd process is running or not? | The.White.Rider | SUN Solaris | 8 | 06-17-2008 07:51 AM |
| check process running | rose1207 | Shell Programming and Scripting | 4 | 12-28-2007 01:23 AM |
| Long Running Web Process (LRWP) in the Java Platform Using GlassFish | iBot | UNIX and Linux RSS News | 0 | 12-23-2007 11:30 PM |
| script to check for a particular process and alert if its not running | goks | Shell Programming and Scripting | 1 | 12-09-2005 05:11 AM |
| How to check if another instance of the process is running | sim | Shell Programming and Scripting | 8 | 06-30-2005 07:24 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
how to check how long the process has been running.
I have a requirement to check how long a process is running on unix system.If i use ps -ef i am getting the following message
guest 2453638 1998920 0 16:16:05 - 0:00 dsapi_slave 9 8 0 but this is showing only time not the date.Can any one please advice me any script to find out how long this process is running. Thanks |
|
||||
|
ps will not help you because it gives you the CPU time. A very simple workaround for this is checking the ctime or mtime of a file created when that process began execution. As such, you can just go ahead and see the date in ls -ld /proc/PID-OF-YOUR-PROCESS.
Example: Code:
Tsunami comparing # ls -ld /proc/1 dr-xr-xr-x 5 root root 0 2008-08-17 22:21 /proc/1 Tsunami comparing # uptime 01:11:18 up 2:50, 5 users, load average: 0.05, 0.06, 0.02 Tsunami comparing # date Mon Aug 18 01:11:24 WEST 2008 Tsunami comparing # |
|
||||
|
"16:16:05" is the start time of the process, so you can subtract that from the current time to calculate how long it has been running.
When the process is more than 24 hours old, this field will contain a date instead of a time. And if, perchance, the process is more than a year old, it will contain the year. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|