[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Is there a way to tell when a system was first booted?



>>>>> shawn wilson <ag4ve.us@gmail.com> writes:
>>>>> On Aug 27, 2011 1:26 PM, "Ivan Shmakov" <ivan@gray.siamics.net> wrote:
>>>>> shawn wilson <ag4ve.us@gmail.com> writes:
>>>>> On Sat, Aug 27, 2011 at 11:43, John A. Sullivan III wrote:

[…]

 >>>> Does "uptime" do what you want or do you mean booted for the truly
 >>>> very first time (not counting reboots)?

 >>> cat /proc/uptime

 >> How's that more legible than the output of the uptime(1)
 >> command?

[…]

 > Nothing.  Iirc uptime parses that file.

	That's correct.

$ strace uptime 2>&1 | grep -F /proc/ 
open("/proc/version", O_RDONLY)         = 4
open("/proc/stat", O_RDONLY|O_CLOEXEC)  = 4
open("/proc/uptime", O_RDONLY)          = 4
open("/proc/loadavg", O_RDONLY)         = 5
$ 

 > For a history of boots, other than a BIOS log, you might look at the
 > acct package, specifically what gets stored in wtmp.

	I don't see how such a wtmp(5) maintenance is tied to the acct
	package.  Consider, e. g.:

$ dpkg -l acct 
No packages found matching acct.
$ last reboot 
reboot   system boot  2.6.XXXXXXXXXXXX Tue Mar 30 03:11 - 18:06 (515+14:55) 
reboot   system boot  2.6.XXXXXXXXXXXX Tue Mar 30 03:10 - 03:11  (00:01)    
reboot   system boot  2.6.XXXXXXXXXXXX Tue Mar 30 02:55 - 03:09  (00:13)    

wtmp begins Tue Mar 30 02:55:59 2010
$ 

	It was my guess that the reboot records are made by init(8).

 > This would not give you anything prior to wtmp being created but
 > might give you what you want.

	Unfortunately, this file is logrotate(8)'d every month, and only
	one backup survives as per the default configuration.

--cut: /etc/logrotate.conf --
# no packages own wtmp, or btmp -- we'll rotate them here
/var/log/wtmp {
    missingok
    monthly
    create 0664 root utmp
    rotate 1
}
--cut: /etc/logrotate.conf --

-- 
FSF associate member #7257	Coming soon: Software Freedom Day
http://mail.sf-day.org/lists/listinfo/ planning-ru (ru), sfd-discuss (en)


Reply to: