47 kB 00:01
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : uptimed-0.4.0-6.el7.x86_64 1/1
Verifying : uptimed-0.4.0-6.el7.x86_64 1/1
Installed:
uptimed.x86_64 0:0.4.0-6.el7
Complete!
如果你正在使用 Fedora Linux,运行以下 dnf 命令:
$ sudo dnf install uptimed
在 Arch Linux 上安装 uptimed
键入以下 pacman 命令:
$ sudo pacman -S uptimed
在 Gentoo Linux 上安装 uptimed
键入以下 emerge 命令:
$ sudo emerge --ask uptimed
如何配置 uptimed
使用文本编辑器编辑 /etc/uptimed.conf 文件,例如 vim 命令:
$ sudo vim /etc/uptimed.conf
最少设置一个 email 地址来发送记录。假定有个兼容 sendmail 的 MTA 安装在 /usr/lib/sendmail。
EMAIL=vivek@server1.cyberciti.biz
保存并关闭文件。
如何在系统启动时启动 uptimed 服务?
使用 systemctl 命令启动 uptimed 服务:
$ sudo systemctl enable uptimed
我该如何 启动/停止/重启 或者查看 uptimed 服务的状态?
$ sudo systemctl start uptimed ## start it ##
$ sudo systemctl stop uptimed ## stop it ##
$ sudo systemctl restart uptimed ## restart it ##
$ sudo systemctl status uptimed ## view status ##
示例输出:
● uptimed.service - uptime record daemon
Loaded: loaded (/lib/systemd/system/uptimed.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2017-11-09 17:49:14 UTC; 18min ago
Main PID: 11137 (uptimed)
CGroup: /system.slice/uptimed.service
└─11137 /usr/sbin/uptimed -f
Nov 09 17:49:14 gfs04 systemd[1]: Started uptime record daemon.
如何查看 uptime 记录
只需键入以下命令即可查看 uptimed(8) 程序的统计信息:
$ uprecords
示例输出:
Fig.02: uprecords in action
Fig.02: uprecords in action
uprecords 有一些选项:
$ uprecords -?
示例输出:
usage: uprecords [OPTION]...
-? this help
-a do not print ansi codes
-b sort by boottime
-B reverse sort by boottime
-k sort by sysinfo
-K reverse sort by sysinfo
-d print downtime seen before every uptimes instead of system
-c do not show current entry if not in top entries
-f run continously in a loop
-s do not print extra statistics
-w wide output (more than 80 cols per line)
-i INTERVAL use INTERVAL seconds for loop instead of 5, implies -f
-m COUNT show a maximum of top COUNT entries instead of 10
-M show next milestone
-v version information
结论
这是一个极好的小工具,可以显示服务器正常运行时间的记录,以证明机器正常运行时间和你的业务连续性。在相关说明中,你可以看到官方的 XKCD 系统管理员 T恤 因为漫画被制作成衬衫,其中包括背面的新插图。
Linux是一套免费使用和自由传播的类Unix操作系统
关键词:怎样记录Linux运行时间统计信息