mirror of
https://github.com/LCTT/TranslateProject.git
synced 2024-12-26 21:30:55 +08:00
[Translated]20150909 Linux Server See the Historical and Statistical Uptime of System With tuptime Utility.md
This commit is contained in:
parent
08173b346e
commit
f4532bfea9
@ -1,15 +1,13 @@
|
|||||||
Translating by GOLinux!
|
使用tuptime工具查看Linux服务器系统历史开机时间统计
|
||||||
Linux Server See the Historical and Statistical Uptime of System With tuptime Utility
|
|
||||||
================================================================================
|
================================================================================
|
||||||
You can use the following tools to see how long system has been running on a Linux or Unix-like system:
|
你们可以使用下面的工具来查看Linux或者类Unix系统运行了多长时间:
|
||||||
|
- uptime : 告诉你服务器运行了多长的时间。
|
||||||
|
- lastt : 显示重启和关机时间。
|
||||||
|
- tuptime : 报告系统的历史运行时间和统计运行时间,这是指重启之间的运行时间。和uptime命令类似,不过输出结果更有意思。
|
||||||
|
|
||||||
- uptime : Tell how long the server has been running.
|
#### 找出系统上次重启时间和日期 ####
|
||||||
- lastt : Show the reboot and shutdown time.
|
|
||||||
- tuptime : Report the historical and statistical running time of system, keeping it between restarts. Like uptime command but with more interesting output.
|
|
||||||
|
|
||||||
#### Finding out the system last reboot time and date ####
|
你[可以使用下面的命令来获取Linux操作系统的上次重启和关机时间及日期][1](在OSX/类Unix系统上也可以用):
|
||||||
|
|
||||||
You [can use the following commands to get the last reboot and shutdown time and date on a Linux][1] operating system (also works on OSX/Unix-like system):
|
|
||||||
|
|
||||||
## Just show system reboot and shutdown date and time ###
|
## Just show system reboot and shutdown date and time ###
|
||||||
who -b
|
who -b
|
||||||
@ -21,28 +19,27 @@ You [can use the following commands to get the last reboot and shutdown time and
|
|||||||
awk '{ print "up " $1 /60 " minutes"}' /proc/uptime
|
awk '{ print "up " $1 /60 " minutes"}' /proc/uptime
|
||||||
w
|
w
|
||||||
|
|
||||||
**Sample outputs:**
|
**样例输出:**
|
||||||
|
|
||||||
![Fig.01: Various Linux commands in action to find out the server uptime](http://s0.cyberciti.org/uploads/cms/2015/09/uptime-w-awk-outputs.jpg)
|
![Fig.01: Various Linux commands in action to find out the server uptime](http://s0.cyberciti.org/uploads/cms/2015/09/uptime-w-awk-outputs.jpg)
|
||||||
|
|
||||||
Fig.01: Various Linux commands in action to find out the server uptime
|
图像01:用于找出服务器开机时间的多个Linux命令
|
||||||
|
|
||||||
**Say hello to tuptime**
|
**跟tuptime问打个招呼吧**
|
||||||
|
|
||||||
The tuptime command line tool can report the following information on a Linux based system:
|
tuptime命令行工具可以报告基于Linux的系统上的下列信息:
|
||||||
|
1. 系统启动次数统计
|
||||||
|
2. 注册首次启动时间(也就是安装时间)
|
||||||
|
1. 正常关机和意外关机统计
|
||||||
|
1. 平均开机时间和故障停机时间
|
||||||
|
1. 当前开机时间
|
||||||
|
1. 首次启动以来的开机和故障停机率
|
||||||
|
1. 累积系统开机时间、故障停机时间和合计
|
||||||
|
1. 报告每次启动、开机时间、关机和故障停机时间
|
||||||
|
|
||||||
1. Count system startups
|
#### 安装 ####
|
||||||
1. Register first boot time (a.k.a. installation time)
|
|
||||||
1. Count nicely and accidentally shutdowns
|
|
||||||
1. Average uptime and downtime
|
|
||||||
1. Current uptime
|
|
||||||
1. Uptime and downtime rate since first boot time
|
|
||||||
1. Accumulated system uptime, downtime and total
|
|
||||||
1. Report each startup, uptime, shutdown and downtime
|
|
||||||
|
|
||||||
#### Installation ####
|
输入[下面的命令来克隆git仓库到Linux系统中][2]:
|
||||||
|
|
||||||
Type the [following command to clone a git repo on a Linux operating system][2]:
|
|
||||||
|
|
||||||
$ cd /tmp
|
$ cd /tmp
|
||||||
$ git clone https://github.com/rfrail3/tuptime.git
|
$ git clone https://github.com/rfrail3/tuptime.git
|
||||||
@ -50,45 +47,45 @@ Type the [following command to clone a git repo on a Linux operating system][2]:
|
|||||||
$ cd tuptime
|
$ cd tuptime
|
||||||
$ ls
|
$ ls
|
||||||
|
|
||||||
**Sample outputs:**
|
**样例输出:**
|
||||||
|
|
||||||
![Fig.02: Cloning a git repo](http://s0.cyberciti.org/uploads/cms/2015/09/git-install-tuptime.jpg)
|
![Fig.02: Cloning a git repo](http://s0.cyberciti.org/uploads/cms/2015/09/git-install-tuptime.jpg)
|
||||||
|
|
||||||
Fig.02: Cloning a git repo
|
图像02:克隆git仓库
|
||||||
|
|
||||||
Make sure you've Python v2.7 installed with sys, optparse, os, re, string, sqlite3, datetime, disutils, and locale modules.
|
确保你随sys,optparse,os,re,string,sqlite3,datetime,disutils安装了Python v2.7和本地模块。
|
||||||
|
|
||||||
You can simply install it as follows:
|
你可以像下面这样来安装:
|
||||||
|
|
||||||
$ sudo tuptime-install.sh
|
$ sudo tuptime-install.sh
|
||||||
|
|
||||||
OR do a manual installation (recommended method due to systemd or non-systemd based Linux system):
|
或者,可以手工安装(根据基于systemd或非systemd的Linux的推荐方法):
|
||||||
|
|
||||||
$ sudo cp /tmp/tuptime/latest/cron.d/tuptime /etc/cron.d/tuptime
|
$ sudo cp /tmp/tuptime/latest/cron.d/tuptime /etc/cron.d/tuptime
|
||||||
|
|
||||||
If is a system with systemd, copy service file and enable it:
|
如果系统是systemd的,拷贝服务文件并启用:
|
||||||
|
|
||||||
$ sudo cp /tmp/tuptime/latest/systemd/tuptime.service /lib/systemd/system/
|
$ sudo cp /tmp/tuptime/latest/systemd/tuptime.service /lib/systemd/system/
|
||||||
$ sudo systemctl enable tuptime.service
|
$ sudo systemctl enable tuptime.service
|
||||||
|
|
||||||
If the systemd don't have systemd, copy init file:
|
如果系统不是systemd的,拷贝初始化文件:
|
||||||
|
|
||||||
$ sudo cp /tmp/tuptime/latest/init.d/tuptime.init.d-debian7 /etc/init.d/tuptime
|
$ sudo cp /tmp/tuptime/latest/init.d/tuptime.init.d-debian7 /etc/init.d/tuptime
|
||||||
$ sudo update-rc.d tuptime defaults
|
$ sudo update-rc.d tuptime defaults
|
||||||
|
|
||||||
**Run it**
|
**运行**
|
||||||
|
|
||||||
Simply type the following command:
|
只需输入以下命令:
|
||||||
|
|
||||||
$ sudo tuptime
|
$ sudo tuptime
|
||||||
|
|
||||||
**Sample outputs:**
|
**样例输出:**
|
||||||
|
|
||||||
![Fig.03: tuptime in action](http://s0.cyberciti.org/uploads/cms/2015/09/tuptime-output.jpg)
|
![Fig.03: tuptime in action](http://s0.cyberciti.org/uploads/cms/2015/09/tuptime-output.jpg)
|
||||||
|
|
||||||
Fig.03: tuptime in action
|
图像03:tuptime工作中
|
||||||
|
|
||||||
After kernel upgrade I rebooted the box and typed the same command again:
|
在更新内核后,我重启了系统,然后再次输入了同样的命令:
|
||||||
|
|
||||||
$ sudo tuptime
|
$ sudo tuptime
|
||||||
System startups: 2 since 03:52:16 PM 08/21/2015
|
System startups: 2 since 03:52:16 PM 08/21/2015
|
||||||
@ -102,11 +99,11 @@ After kernel upgrade I rebooted the box and typed the same command again:
|
|||||||
System downtime: 5 hours, 0 minutes and 11 seconds
|
System downtime: 5 hours, 0 minutes and 11 seconds
|
||||||
System life: 15 days, 14 hours, 36 minutes and 18 seconds
|
System life: 15 days, 14 hours, 36 minutes and 18 seconds
|
||||||
|
|
||||||
You can change date and time format as follows:
|
你可以像下面这样修改日期和时间格式:
|
||||||
|
|
||||||
$ sudo tuptime -d '%H:%M:%S %m-%d-%Y'
|
$ sudo tuptime -d '%H:%M:%S %m-%d-%Y'
|
||||||
|
|
||||||
**Sample outputs:**
|
**样例输出:**
|
||||||
|
|
||||||
System startups: 1 since 15:52:16 08-21-2015
|
System startups: 1 since 15:52:16 08-21-2015
|
||||||
System shutdowns: 0 ok - 0 bad
|
System shutdowns: 0 ok - 0 bad
|
||||||
@ -119,11 +116,11 @@ You can change date and time format as follows:
|
|||||||
System downtime: 0 seconds
|
System downtime: 0 seconds
|
||||||
System life: 15 days, 9 hours, 21 minutes and 19 seconds
|
System life: 15 days, 9 hours, 21 minutes and 19 seconds
|
||||||
|
|
||||||
Enumerate each startup, uptime, shutdown and downtime:
|
计算每次启动、开机时间、关机和故障停机时间:
|
||||||
|
|
||||||
$ sudo tuptime -e
|
$ sudo tuptime -e
|
||||||
|
|
||||||
**Sample outputs:**
|
**样例输出:**
|
||||||
|
|
||||||
Startup: 1 at 03:52:16 PM 08/21/2015
|
Startup: 1 at 03:52:16 PM 08/21/2015
|
||||||
Uptime: 15 days, 9 hours, 22 minutes and 33 seconds
|
Uptime: 15 days, 9 hours, 22 minutes and 33 seconds
|
||||||
@ -144,7 +141,7 @@ Enumerate each startup, uptime, shutdown and downtime:
|
|||||||
via: http://www.cyberciti.biz/hardware/howto-see-historical-statistical-uptime-on-linux-server/
|
via: http://www.cyberciti.biz/hardware/howto-see-historical-statistical-uptime-on-linux-server/
|
||||||
|
|
||||||
作者:Vivek Gite
|
作者:Vivek Gite
|
||||||
译者:[译者ID](https://github.com/译者ID)
|
译者:[GOLinux](https://github.com/GOLinux)
|
||||||
校对:[校对者ID](https://github.com/校对者ID)
|
校对:[校对者ID](https://github.com/校对者ID)
|
||||||
|
|
||||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
Loading…
Reference in New Issue
Block a user