LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
楼主: wkt

如何查看linux什么时候开机?

[复制链接]
 楼主| 发表于 2009-4-18 21:08:02 | 显示全部楼层
Post by kgnn;1976243
看log呢?
/var/log/messages
/var/log/syslog

比如
$grep "0\.000000" /var/log/syslog |tail -n 1
Apr 18 13:06:37 debian kernel: [    0.000000] Detected 1102.570 MHz processor.


此法不通用
$ sudo grep '000000' /var/log/syslog | tail -n5
Apr 18 14:10:14 asuspc kernel: pci 0000:00:1c.4:   PREFETCH window: 0x000000f5f00000-0x000000f7efffff
Apr 18 14:10:14 asuspc kernel: pci_bus 0000:00: resource 1 mem: [0x000000-0xffffffff]
Apr 18 14:10:14 asuspc kernel: pci_bus 0000:01: resource 1 mem: [0xf8000000-0xfe0fffff]
Apr 18 14:10:14 asuspc kernel: pci_bus 0000:08: resource 4 mem: [0x000000-0xffffffff]
Apr 18 14:10:14 asuspc kernel: eth0: RTL8168b/8111b at 0xf80ac000, 00:22:15:9e:54:46, XID 38000000 IRQ 30
回复 支持 反对

使用道具 举报

发表于 2009-4-18 21:20:23 | 显示全部楼层
我的方法,命令w或者who,看登录tty1的时间
回复 支持 反对

使用道具 举报

发表于 2009-4-18 23:05:02 | 显示全部楼层
Post by wkt;1976292
此法不通用
$ sudo grep '000000' /var/log/syslog | tail -n5
Apr 18 14:10:14 asuspc kernel: pci 0000:00:1c.4:   PREFETCH window: 0x000000f5f00000-0x000000f7efffff
Apr 18 14:10:14 asuspc kernel: pci_bus 0000:00: resource 1 mem: [0x000000-0xffffffff]
Apr 18 14:10:14 asuspc kernel: pci_bus 0000:01: resource 1 mem: [0xf8000000-0xfe0fffff]
Apr 18 14:10:14 asuspc kernel: pci_bus 0000:08: resource 4 mem: [0x000000-0xffffffff]
Apr 18 14:10:14 asuspc kernel: eth0: RTL8168b/8111b at 0xf80ac000, 00:22:15:9e:54:46, XID 38000000 IRQ 30

你去找000000当然到处是
不知道你的怎么没有类似这种时间记录[    0.000000]
我只是说个方法,具体实施自己变通,log里是有时间记录的,自己找只有刚启动时才有的内核消息作为参考
$dmesg |head -n5
[    0.000000] Initializing cgroup subsys cpuset
[    0.000000] Initializing cgroup subsys cpu
[    0.000000] Linux version 2.6.26-2-686 (Debian 2.6.26-15) (dannf@debian.org) (gcc version 4.1.3 20080704 (prerelease) (Debian 4.1.2-25)) #1 SMP Thu Mar 26 01:08:11 UTC 2009
[    0.000000] BIOS-provided physical RAM map:
[    0.000000]  BIOS-e820: 0000000000000000 - 000000000009fc00 (usable)
$ grep 'Initializing cgroup subsys cpuset' /var/log/syslog |tail -n3
Apr 18 09:56:13 debian kernel: [    0.000000] Initializing cgroup subsys cpuset
Apr 18 13:06:37 debian kernel: [    0.000000] Initializing cgroup subsys cpuset
Apr 18 19:09:39 debian kernel: [    0.000000] Initializing cgroup subsys cpuset
$ grep 'BIOS-provided physical RAM map' /var/log/syslog |tail -n3
Apr 18 09:56:13 debian kernel: [    0.000000] BIOS-provided physical RAM map:
Apr 18 13:06:37 debian kernel: [    0.000000] BIOS-provided physical RAM map:
Apr 18 19:09:39 debian kernel: [    0.000000] BIOS-provided physical RAM map:
又或者
$ head -n1 /var/log/syslog
Apr 13 22:45:47 debian kernel: imklog 3.18.6, log source = /proc/kmsg started.
$ grep 'imklog 3.18.6' /var/log/syslog|tail -n3
Apr 18 09:56:13 debian kernel: imklog 3.18.6, log source = /proc/kmsg started.
Apr 18 13:06:37 debian kernel: imklog 3.18.6, log source = /proc/kmsg started.
Apr 18 19:09:39 debian kernel: imklog 3.18.6, log source = /proc/kmsg started.
回复 支持 反对

使用道具 举报

 楼主| 发表于 2009-4-18 23:06:20 | 显示全部楼层
Post by adaml;1976302
我的方法,命令w或者who,看登录tty1的时间

使用这个方法,我觉得是无奈的选择
$who
wkt      tty7         2009-04-18 14:12 (:0)
wkt      pts/0        2009-04-18 14:12 (:0.0)
wkt      pts/1        2009-04-18 14:13 (:0.0)
wkt      pts/2        2009-04-18 16:02 (:0.0)

如果开机之后,很久才登录呢?
回复 支持 反对

使用道具 举报

 楼主| 发表于 2009-4-18 23:10:47 | 显示全部楼层
Post by kgnn;1976352
你去找000000当然到处是
不知道你的怎么没有类似这种时间记录[    0.000000]
我只是说个方法,具体实施自己变通,log里是有时间记录的,自己找只有刚启动时才有的内核消息作为参考
dmesg |head -n5
[    0.000000] Initializing cgroup subsys cpuset
[    0.000000] Initializing cgroup subsys cpu
[    0.000000] Linux version 2.6.26-2-686 (Debian 2.6.26-15) (dannf@debian.org) (gcc version 4.1.3 20080704 (prerelease) (Debian 4.1.2-25)) #1 SMP Thu Mar 26 01:08:11 UTC 2009
[    0.000000] BIOS-provided physical RAM map:
[    0.000000]  BIOS-e820: 0000000000000000 - 000000000009fc00 (usable)
$grep 'Initializing cgroup subsys cpuset' /var/log/syslog |tail -n 1
Apr 18 19:09:39 debian kernel: [    0.000000] Initializing cgroup subsys cpuset


-1-$ sudo grep  '0\.000000' /var/log/dmesg
wkt@asuspc:~
-1-$ sudo grep  '0\.000000' /var/log/syslog
什么都没有!你的是不是ubuntu啊?
回复 支持 反对

使用道具 举报

 楼主| 发表于 2009-4-18 23:13:43 | 显示全部楼层
$grep 'Initializing cgroup subsys cpuset' /var/log/syslog |tail -n 1
Apr 18 19:09:39 debian kernel: [ 0.000000] Initializing cgroup subsys cpuset
---这个好像可以

不过
-0-$ sudo grep 'Initializing cgroup subsys cpuset' /var/log/syslog |tail
Apr 15 08:54:16 asuspc kernel: Initializing cgroup subsys cpuset
Apr 15 19:25:17 asuspc kernel: Initializing cgroup subsys cpuset
Apr 16 15:55:53 asuspc kernel: Initializing cgroup subsys cpuset
Apr 16 15:58:05 asuspc kernel: Initializing cgroup subsys cpuset
Apr 16 18:52:21 asuspc kernel: Initializing cgroup subsys cpuset
Apr 16 21:50:06 asuspc kernel: Initializing cgroup subsys cpuset
Apr 17 08:55:31 asuspc kernel: Initializing cgroup subsys cpuset
Apr 17 19:01:27 asuspc kernel: Initializing cgroup subsys cpuset
Apr 18 09:45:31 asuspc kernel: Initializing cgroup subsys cpuset
Apr 18 14:10:14 asuspc kernel: Initializing cgroup subsys cpuset
不过一哪个为准呢?
回复 支持 反对

使用道具 举报

发表于 2009-4-18 23:30:12 | 显示全部楼层
晕啊,当然每次启动都有记录
最下面一行就是这次启动的时间啊。。。
tail -n1 只显示最后一次就是了嘛

还有,我是Debian lenny,只用stable
回复 支持 反对

使用道具 举报

 楼主| 发表于 2009-4-22 01:25:11 | 显示全部楼层
再顶一次,看看还有没有其他办法了!!
回复 支持 反对

使用道具 举报

发表于 2009-4-22 09:24:38 | 显示全部楼层
[php]
ubuntu:~$ ls -l /proc/1/cmdline
-r--r--r-- 1 root root 0 2009-04-10 11:37 /proc/1/cmdline
[/php]
我感觉这个可以用。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2009-4-22 09:42:29 | 显示全部楼层
Post by wide288;1977765
[php]
ubuntu:~$ ls -l /proc/1/cmdline
-r--r--r-- 1 root root 0 2009-04-10 11:37 /proc/1/cmdline
[/php]
我感觉这个可以用。

我都说了这个不可靠!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表