Reading package lists... Done Building dependency tree Reading state information... Done The following additional packages will be installed: libuptimed0 The following NEW packages will be installed: libuptimed0 uptimed 0 upgraded, 2 newly installed, 0 to remove and 3 not upgraded. Need to get 40.7 kB of archives. After this operation, 228 kB of additional disk space will be used. Do you want to continue? [Y/n] y Get:1 http://mirrors.linode.com/ubuntu xenial/universe amd64 libuptimed0 amd64 1:0.3.17-4 [9,050B] Get:2 http://mirrors.linode.com/ubuntu xenial/universe amd64 uptimed amd64 1:0.3.17-4 [31.6 kB] Fetched40.7 kB in 0s (2,738 kB/s) Preconfiguring packages ... Selecting previously unselected package libuptimed0. (Reading database ... 39163 files and directories currently installed.) Preparing to unpack .../libuptimed0_1%3a0.3.17-4_amd64.deb ... Unpacking libuptimed0 (1:0.3.17-4) ... Selecting previously unselected package uptimed. Preparing to unpack .../uptimed_1%3a0.3.17-4_amd64.deb ... Unpacking uptimed (1:0.3.17-4) ... Processing triggers for systemd (229-4ubuntu21) ... Processing triggers for ureadahead (0.100.0-19) ... Processing triggers for man-db (2.7.5-1) ... Setting up libuptimed0 (1:0.3.17-4) ... Setting up uptimed (1:0.3.17-4) ... Processing triggers for libc-bin (2.23-0ubuntu9) ... Processing triggers for systemd (229-4ubuntu21) ... Processing triggers for ureadahead (0.100.0-19) ...
在 CentOS/RHEL/Fedora/Oracle/Scientific Linux 上安装 uptimed
Total download size: 47 k Installed size: 98 k Is this ok [y/d/N]: y Downloading packages: uptimed-0.4.0-6.el7.x86_64.rpm | 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 命令:
1 2
$ sudo dnf install uptimed
在 Arch Linux 上安装 uptimed
键入以下 pacman 命令:
1 2
$ sudo pacman -S uptimed
在 Gentoo Linux 上安装 uptimed
键入以下 emerge 命令:
1 2
$ sudo emerge --ask uptimed
如何配置 uptimed
使用文本编辑器编辑 /etc/uptimed.conf 文件,例如 vim 命令:
1 2
$ sudo vim /etc/uptimed.conf
最少设置一个 email 地址来发送记录。假定有个兼容 sendmail 的 MTA 安装在 /usr/lib/sendmail。
1 2
EMAIL=vivek@server1.cyberciti.biz
保存并关闭文件。
如何在系统启动时启动 uptimed 服务?
使用 systemctl 命令启动 uptimed 服务:
1 2
$ sudo systemctl enable uptimed
我该如何 启动/停止/重启 或者查看 uptimed 服务的状态?
1 2 3 4 5
$ sudo systemctl start uptimed ## start it ## $ sudo systemctl stop uptimed ## stop it ## $ sudo systemctl restart uptimed ## restart it ## $ sudo systemctl status uptimed ## view status ##
示例输出:
1 2 3 4 5 6 7 8 9
● uptimed.service - uptime record daemon Loaded: loaded (/lib/systemd/system/uptimed.service;enabled; vendor preset: enabled) Active: active (running) since Thu 2017-11-0917:49:14 UTC;18min ago Main PID: 11137 (uptimed) CGroup: /system.slice/uptimed.service └─11137/usr/sbin/uptimed -f
Nov 0917:49:14 gfs04 systemd[1]: Started uptime record daemon.
如何查看 uptime 记录
只需键入以下命令即可查看 uptimed(8) 程序的统计信息:
1 2
$ uprecords
示例输出:
uprecords 有一些选项:
1 2
$ uprecords -?
示例输出:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
usage: uprecords [OPTION]...
-? this help -a do not print ansi codes -b sortby boottime -B reverse sortby boottime -k sortby sysinfo -K reverse sortby sysinfo -dprint 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 -mCOUNT show a maximum of top COUNT entries instead of 10 -M show next milestone -v version information