To find out the timestamp when the process started, you have to calc a bit. Use this command:
echo "$(date +%s) - $(ps -o etime --no-headers -p $pid | \
awk -F'[:-]' '{print ($4+($3*60)+($2*60*60)+($1*24*60*60))}')" | bc -l
The value of $pid
should be the process id.
Explanation:
echo "$(date +%s)
: print the timestamp of now
ps -o etime --no-headers -p $pid
: print the elapsed time of the process without headers
awk -F'[:-]'
: set the delimiter of awk
to :
and -
because the time will be printed in the following format: dd-hh:mm:ss
'{print ($4+($3*60)+($2*60*60)+($1*24*60*60))}'
calculate the values in seconds
bc -l
: and pipe the output to bc
(timestamp_now - elapsed_seconds = timespamp_at_process_start
)
For exmaple i tested it with the init process of a system that runs for 42 days. The output was 1406124152
, which is the 07 / 23 / 14 @ 2:02:31pm UTC
.
/proc/29137
exist on your system?stat
a file in there to get the exact time./proc/<PID>
time will be the timestamp the (virtual) directory was created. It gets created the first time something tries to access it (ls
,ps
, etc).