Date of a FreeBSD installation

David Demelier demelier.david at gmail.com
Wed Jan 26 17:00:54 UTC 2011


On 14/01/2011 19:46, Carl Johnson wrote:
> Chip Camden<sterling at camdensoftware.com>  writes:
>
>> Quoth Carl Chave on Friday, 14 January 2011:
>>>> I'd suggest looking at the Btimes of top level directories
>>>>
>>>> stat -f "%SB %N" /*
>>>
>>> Or how about just / as this ~15 minutes earlier than most of the
>>> remaining top level directories
>>>
>>>
>>> sodserve# stat -f "%SB %N" /*
>>> Jan  9 04:54:21 2011 /COPYRIGHT
>>> Jan  9 04:54:21 2011 /bin
>>> Jan  9 04:54:21 2011 /boot
>>> Dec 31 18:59:59 1969 /dev
>>> Jan  9 04:54:21 2011 /etc
>>> Jan  9 04:54:21 2011 /lib
>>> Jan  9 04:54:21 2011 /libexec
>>> Jan  9 04:54:21 2011 /media
>>> Jan  9 04:54:21 2011 /mnt
>>> Jan  9 04:54:21 2011 /proc
>>> Jan  9 04:54:21 2011 /rescue
>>> Jan  9 04:54:21 2011 /root
>>> Jan  9 04:54:21 2011 /sbin
>>> Jan  9 04:54:21 2011 /sys
>>> Jan  9 04:48:39 2011 /tmp
>>> Jan  9 04:48:45 2011 /usr
>>> Jan  9 04:49:39 2011 /var
>>>
>>> sodserve# stat -f "%SB %N" /
>>> Jan  9 04:39:59 2011 /
>>
>> For me, that gets the Nov 21 2009 date, which is earlier than my
>> install date.
>>
>> So far, /etc/hostid and the /home symlink seem to be the winners.
>
> On my system /etc/hostid is several days later than my actual install
> date, so that isn't always reliable.  You might want to create a file
> with the timestamp you want.  The most likely time appears to me to be
> the 'Created' time in /etc/rc.conf, as someone suggested earlier.  The
> following code will extract that and create a file with that timestamp.
> I have checked it on my system, but use at your own risk.
>
> file=/etc/install_date
> date=$(grep '^# Created: ' /etc/rc.conf | cut -c 12-80)
> tdate=$(date -j -f "%a %b %d %H:%M:%S %Y" "$date" "+%Y%m%d%H%M.%S")
> echo $date>  $file
> touch -t $tdate $file
> chmod -w $file
> chflags schange $file
>

I finally agreed for /home symlink. I've made a mistake. To be sure the 
link and not the directory /usr/home is touched the best to do is :

# chflags -h uchg /home

-h means "not following links"

-- 
David Demelier


More information about the freebsd-questions mailing list