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:

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.

"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.