openbsd 关机和开机的时间 查看?

OpenBSD的安装、升级、更新等日常问题。

版主: chenjun天地乾坤

回复
openbsdsir008
铁 Fe
帖子: 80
注册时间: 2014-03-20 16:19

openbsd 关机和开机的时间 查看?

帖子 openbsdsir008 » 2014-08-13 18:52

家中有一个6网口的intel 1037u主机。安装的是openbsd5.5.
adsl 光纤猫拨号上网,openbsd 上安装了noip2,可以远程登录管理。

家中经常停电,然后又来电了.openbsd 主机可以来电自动启动。

如何知道openbsd主机,何时停电了,何时又来电了?

有几种方法?

头像
acheng
锌 Zn
帖子: 581
注册时间: 2011-07-07 21:52

Re: openbsd 关机和开机的时间 查看?

帖子 acheng » 2014-08-14 12:34

开机时间和关机时间可以通过last来看 (不过意外断电导致的关机、重启可能不会被记录)

代码: 全选


[acheng@puffy ~]$ last

acheng    ttyp1    117.63.177.19            Tue Apr 16 08:31 - 09:28  (00:57)
acheng    ttyp0    114.226.3.151            Tue Apr 16 08:07 - 09:06  (00:58)
reboot    ~                                 Tue Apr 16 08:05 
shutdown  ~                                 Tue Apr 16 08:04 
acheng    ttyp1    114.226.3.151            Tue Apr 16 07:51 - shutdown  (00:12)
acheng    ttyp0    114.226.14.63            Tue Apr 16 05:49 - 08:00  (02:11)
也可以通过uptime来计算开机时间。如果知道关机和开机之间没有时间间隔的话,也可以推算出大致的关机时间。

代码: 全选

[acheng@puffy ~]$ uptime
 9:34PM  up 484 days, 13:29, 1 user, load averages: 0.20, 0.21, 0.27
另外,意外断电,也可以通过查看系统日志,如果发现从某个时间点开始系统日志突然中断了,也可以认为那段时间是断电的

openbsdsir008
铁 Fe
帖子: 80
注册时间: 2014-03-20 16:19

Re: openbsd 关机和开机的时间 查看?

帖子 openbsdsir008 » 2014-08-31 22:57

意外停电显示为:reboot,没有shutdown 的显示
Sat Aug 30 21:58 那个时间意外停电了
#last
root ttyp0 31.45.105.5 Sun Aug 31 20:19 - 21:05 (00:46)
reboot ~ Sun Aug 31 07:20
root ttyp3 31.45.105.5 Sat Aug 30 21:58 - crash (09:22)




last默认显示多少行?
能不能让last命令显示的多一些?

头像
bsdplus
铁 Fe
帖子: 77
注册时间: 2013-08-16 12:02

Re: openbsd 关机和开机的时间 查看?

帖子 bsdplus » 2014-09-01 13:53

last -n 20
=acheng

openbsdsir008
铁 Fe
帖子: 80
注册时间: 2014-03-20 16:19

Re: openbsd 关机和开机的时间 查看?

帖子 openbsdsir008 » 2014-09-01 20:34

wtmp begins Sat Aug 30 11:42 2014




这个时间点之前的就看不到了

头像
bsdplus
铁 Fe
帖子: 77
注册时间: 2013-08-16 12:02

Re: openbsd 关机和开机的时间 查看?

帖子 bsdplus » 2014-09-10 13:53

那要看你的wtmp日志文件是否都被清掉。如果还有其它的,比如wtmp.0, wtmp.1等等,你可以用:

last -f /var/tmp/wtmp.0 来看更早以前的。

如果都没有保留,那就只能看到那么多了
=acheng

回复

在线用户

正浏览此版面之用户: Ahrefs [Bot] 和 6 访客