|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | 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. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
| Sponsored Links | ||
|
|
#2
|
|||
|
|||
|
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 # The creation of init process (PID 1) is more or less when the system started. |
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
"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. |
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Monitor a long running process | sunpraveen | Shell Programming and Scripting | 4 | 05-11-2010 02:46 PM |
| How to check if process is running? | ladyAnne | UNIX and Linux Applications | 5 | 05-01-2010 01:20 AM |
| How to check since when (for how long) a particular process is running ? | hpuxlxboy | UNIX for Advanced & Expert Users | 2 | 02-19-2009 07:14 AM |
| check process running | rose1207 | Shell Programming and Scripting | 4 | 12-28-2007 12:23 AM |
|
|