Reputation: 1545
On Unix systems PID is unique only at any given point in time. It is not unique in a given time interval because PIDs used in the past can be re-used after the original process terminates. For storing of history data of all the processes which were running on the system since boot I need identifiers to be unique since the boot.
Is there any standard or best practise for that? Is there anything wrong or missing in my intended solution below?
It seems logical to use PID together with the process start time (as standard Unix time) as a unique process identifier. Such identifier would be even unique between reboots.
Advantages
Disadvantages
ps
. For example in shell: date -d "$(ps -p $PID -o lstart=)" +%s
. In Linux it is possible to compute the process start time from /proc/$PID/stat
but this method does not work on other systems.Upvotes: 3
Views: 1103
Reputation: 11
ntp service always adjusts system time, which influences start time read from "ps -p $pid -o lstart". As a result, you are able to got a different start time after system time adjusted.
Upvotes: 1