`
icarusli
  • 浏览: 525682 次
  • 性别: Icon_minigender_1
  • 来自: 广州
社区版块
存档分类
最新评论

Linux last reboot time and date find out

阅读更多
So how do you find Linux / UNIX system last reboot or shutdown date and time? The last utility will either list the sessions of specified users, ttys, and hosts, in reverse time order, or list the users logged in at a specified date and time. Each line of output contains the user name, the tty from which the session was conducted, any hostname, the start and stop times for the session, and the duration of the session.

who command
You need to use who command, to print who is logged on. It also displays the time of last system boot. Use last command to display system reboot and shutdown date and time.

$ who –b

Output:

system boot  Apr 30 15:08Use last command to display listing of last logged in users and system last reboot time and date:

$ last reboot | less

Or better try:

$ last reboot | head -1

Output:

reboot   system boot  2.6.15.4         Sun Apr 30 15:08 - 16:22  (01:13)last command searches back through the file /var/log/wtmp and displays a list of all users logged in (and out) since that file was created. The pseudo user reboot logs in each time the system is rebooted. Thus last reboot command will show a log of all reboots since the log file was created.

To display last shutdown date and time use following command:

$ last -x|grep shutdown | head -1

Output:

shutdown system down  2.6.15.4         Sun Apr 30 13:31 - 15:08  (01:37)Where,

-x: Display the system shutdown entries and run level changes.
For more information read last command man page.


http://www.cyberciti.biz/tips/linux-last-reboot-time-and-date-find-out.html


------------------
2 diana 10.15.07 at 12:57 pm
i couldn’t find out the error. please help me.

#Send list of users logged on to server via email
59 11 * * * last | grep date ‘+%a %b %d’ > /tmp/users.out ; mail -s “Users Logged Today” ephrondiana@gmail.com

when i tried to execute,
$ last |grep date ‘+%a %b %d’
i got no such file or directory error.

3 vivek 10.15.07 at 1:06 pm
Should be..
59 11 * * * last | grep $(date '+%a %b %d') > /tmp/users.out ; mail -s “Users Logged"

4 diana 10.15.07 at 1:25 pm
thanks a lot vivek.i din’t expect this much fast reply.But unfortunately when i execute,
$ last | grep $(date ‘+%a %b %d’)
i couldn’t get anything.Please help

5 vivek 10.15.07 at 2:12 pm
My bad…I forgot to include double quote …

59 11 * * * last | grep "$(date '+%a %b %d')" > /tmp/users.out ; mail -s “Users Logged"Also you may wanna try out:

last -t yyyymmddhhmmssHTH


分享到:
评论

相关推荐

    linux命令c语言自己实现(大概40来个)

    自己学习《APUE》时写的linux下一些命令(大概40个左右)实现,仅当学习使用,这些命令包括cat cp echo head ls paste rmdir tail umask who chattr cut expand join mkdir pwd sed tee uniq chgrp date find last ...

    Linux命令搜索工具linux-command.zip

    adduser、chfn、chsh、date、exit、finger、free、fwhois、gitps、groupdel、groupmod、halt、id、kill、last、lastb、login、logname、logout、logrotate、newgrp、nice、procinfo、ps、pstree、reboot、renice、...

    linux全志R16的linux系统编译的资料_20170502_1655.7z

    config/autoconf.h KCONFIG_TRISTATE=/home/wwt/linux_r16/lichee/out/sun8iw5p1/linux/common/buildroot/build/buildroot-config/tristate.config BUILDROOT_CONFIG=/home/wwt/linux_r16/lichee/out/sun8iw5p1/...

    Linux命令大全完整版

    Linux命令大全完整版 目 录 目 录 I 1. linux系统管理命令 1 adduser 1 chfn(change finger information) 1 chsh(change shell) 1 date 2 exit 3 finger 4 free 5 fwhois 5 gitps(gnu interactive tools ...

    Linux命令大全(CHM格式离线版)

    Linux命令大全(CHM格式离线版) Linux命令大全(修改版) 进行重新编译的说明 文件传输 bye ftp ftpcount ftpshut ftpwho ncftp tftp uucico uucp uupick uuto 备份压缩 ar bunzip2 bzip2 bzip2recover compress cpio ...

    redhat linux教材20课程学习文档

    第一部分 Linux简介和原理介绍 第一章 概述 1.1 Linux 的历史及背景 1.1.1 什么是 Linux? 1.1.2 Linux 该怎么念? 1.1.3 Linux 的历史 1.1.4 Linux的优点 1.2 Linux与开源软件 1.3 Linux 与 Windows 的比较 1.3.1 ...

    Linux命令大全

    linux命令大全,中文版本 Linux命令大全(修改版) 进行重新编译的说明 文件传输 bye ftp ftpcount ftpshut ftpwho ncftp tftp uucico uucp uupick uuto 备份压缩 ar bunzip2 bzip2 bzip2recover compress cpio dump ...

    Linux命令笔记

    1:find 文件搜索 语法:find [搜索范围][比配条件] 2:locate 在文件资料库中查找文件 语法:locate 文件名 3:which 搜索命令所在目录级别名信息 语法:which[命令名称] 4:whereis 搜索命令所在目录级帮助文档路径 ...

    VB编程资源大全(英文源码 网络)

    You can send messages with a client/server type setup.<END><br>57 , al40.zip Apparently, if you use AOL to connect to the Internet and you do not touch it for 45 minutes it will timeout and drop ...

    Linux指令一周通 (技术图书大系).azw3

    6.48 up2date指令:更新Linux系统 6.49 vmstat指令:显示虚拟内存空间 第7天 其他常见指令 7.1 as指令:标准GNU汇编程序 7.2 autoconf指令:产生配置脚本 7.3 autoheader指令:为configure产生模板头文件 7.4 ...

    grub4dos-V0.4.6a-2017-02-04更新

    --timeout=[x]=[y]=[color] 倒计时位置、颜色。单位:列,行,24位色彩。 2015-05-14(yaya) 改进 NTFS 文件系统: 对于驻留属性文件(小文件),可以写,也可用 blocklist 显示信息。 对于非驻留属性列表,...

    uboott移植实验手册及技术文档

    4、交叉编译器 arm-softfloat-linux-gnu-gcc-3.4.5 【实验步骤】 一、建立自己的平台类型 (1)解压文件 #tar jxvf u-boot-1.3.1.tar.bz2 (2)进入 U-Boot源码目录 #cd u-boot-1.3.1 (3)创建自己的开发板...

    ubuntu部落(适合初学者,可以作为初学者的手册)

    Ubuntu 相对其它Linux 发行版的主要特点.. 2 基本操作................................................................... 3 进入系统........................................................... 3 命令行提示...

Global site tag (gtag.js) - Google Analytics