Linux command: echo "" | sudo tee /var/log/messages

echo "" | sudo tee /var/log/messages

命令: echo
功能: 在显示器上显示一段文字,一般起到一个提示的作用.

命令: tee
功能:
读取标准输入的数据,并将其内容输出成文件.
(补充: tee指令会从标准输入设备读取数据,将其内容输出到标准输出设备,同时保存成文件.我们可利用tee把管道导入的数据存成文件,甚至一次保存数份文件.)

格式: tee
只输出到标准输出.

格式: tee file
输出到标准输出的同时,保存到文件file中.如果文件不存在,则创建;如果已经存在,则覆盖.

格式: tee -a file
输出到标准输出的同时,追加到文件file中.如果文件不存在,则创建;如果已经存在,就在末尾追加内容,而不是覆盖.

举例:

[[email protected] bin]# cat /var/log/messages
Mar 15 03:28:01 localhost rsyslogd: [origin software="rsyslogd" swVersion="5.8.10" x-pid="1953" x-info="http://www.rsyslog.com"] rsyslogd was HUPed
Mar 15 03:28:02 localhost rhsmd: In order for Subscription Manager to provide your system with updates, your system must be registered with the Customer Portal. Please enter your Red Hat login to ensure your system is up-to-date.
Mar 15 19:09:14 localhost kernel: psmouse.c: Wheel Mouse at isa0060/serio1/input0 lost synchronization, throwing 1 bytes away.
Mar 15 19:09:15 localhost kernel: psmouse.c: resync failed, issuing reconnect request
Mar 16 03:03:06 localhost dhclient[2039]: DHCPREQUEST on eth0 to 10.237.80.131 port 67 (xid=0x3a80f229)
Mar 16 03:03:06 localhost dhclient[2039]: DHCPACK from 10.237.80.131 (xid=0x3a80f229)
Mar 16 03:03:06 localhost dhclient[2039]: bound to 10.237.88.109 -- renewal in 340498 seconds.
Mar 16 03:03:06 localhost NetworkManager[2018]: <info> (eth0): DHCPv4 state changed renew -> renew
Mar 16 03:03:06 localhost NetworkManager[2018]: <info> address 10.237.88.109
Mar 16 03:03:06 localhost NetworkManager[2018]: <info> prefix 23 (255.255.254.0)
Mar 16 03:03:06 localhost NetworkManager[2018]: <info> gateway 10.237.88.1
Mar 16 03:03:06 localhost NetworkManager[2018]: <info> nameserver ‘10.237.80.131‘
Mar 16 03:03:06 localhost NetworkManager[2018]: <info> domain name ‘acschina.com‘
Mar 16 03:41:18 localhost rhsmd: In order for Subscription Manager to provide your system with updates, your system must be registered with the Customer Portal. Please enter your Red Hat login to ensure your system is up-to-date.
Mar 17 03:13:43 localhost rhsmd: In order for Subscription Manager to provide your system with updates, your system must be registered with the Customer Portal. Please enter your Red Hat login to ensure your system is up-to-date.
Mar 18 03:37:07 localhost rhsmd: In order for Subscription Manager to provide your system with updates, your system must be registered with the Customer Portal. Please enter your Red Hat login to ensure your system is up-to-date.
[[email protected] bin]# echo "" | tee /var/log/messages

[[email protected] bin]# cat /var/log/messages

[[email protected] bin]#

时间: 2024-11-05 01:01:57

Linux command: echo "" | sudo tee /var/log/messages的相关文章

Linux command: rsync -avz /var/log/messages /opt/ops/messages-2015031i0

rsync -avz /var/log/messages /opt/ops/messages-20150310 工具:rsync 简介: rsync是Unix下的一款应用软件,它能同步更新两处计算机的文件与目录,并适当利用差分编码以减少数据传输. rsync中一项与其他大部分类似程序或协议中所未见的重要特性是镜像对每个目标只需要一次发送. rsync可拷贝/显示目录属性,以及拷贝文件,并可选择性的压缩以及递归拷贝.***提示:Rsync 还可以实现类似rm的删除功能(--process --de

删除了linux系统上/var/log/messages该怎么?

删除了linux系统上/var/log/messages该怎么? 安装lsof 查看/var/log/messages文件的进程pid,fd,command 恢复/var/log/messages 重启rsyslogd服务 # yum install lsof -y # lsof|grep /var/log/messages rsyslogd 12475 root 6w REG 8,3 172822 33612673 /var/log/messages (deleted) in:imjour 1

【翻译自mos文章】Linux的/var/log/messages是空的(0k),messages.0, messages.1也是空的

Linux的/var/log/messages是空的(0k),messages.0, messages.1也是空的 来源于: The /var/log/messages is empty, and so are the rotated log files such as messages.0, messages.1,... (文档 ID 2053885.1) 适用于: Linux OS - Version Enterprise Linux 4.0 to Oracle Linux 7.1 with

[转]ubuntu12.04没有/var/log/messages解决

编辑/etc/rsyslog.d/50-default.conf 其中有这么一段 *.=info;*.=notice;*.=warn;\ auth,authpriv.none;\ cron,daemon.none;\ mail,news.none        -/var/log/messages 保存后重启服务:sudo restart rsyslog   [转]ubuntu12.04没有/var/log/messages解决,布布扣,bubuko.com

/var/log/messages

messages 日志是核心系统日志文件.它包含了系统启动时的引导消息,以及系统运行时的其他状态消息.IO 错误.网络错误和其他系统错误都会记录到这个文件中.其他信息,比如某个人的身份切换为 root,也在这里列出.如果服务正在运行,比如 DHCP 服务器,您可以在 messages 文件中观察它的活动.通常,/var/log/messages 是您在做故障诊断时首先要查看的文件. 时间   用户 事件 Dec 21 23:05:57 iZ2ze4dm78raiqat6xo1q0Z kernel

解决无/var/log/messages 问题

转载于:https://blog.csdn.net/C_Major/article/details/51321684 1 内核编程insmod后,Ubuntu查看日志无/var/log/messages 写好简单内核模块如hellomod.ko后,执行命令 insmod hellomod.ko 后,查看内核打印的printk信息, tail /var/log/messages 后发现并没有messages文件. 2 Ubuntu是有/var/log/messages这个文件的! root@XXX

误删/var/log/messages的恢复方法

执行 [[email protected] log]# lsof |grep /var/log/messages 显示 rsyslogd  1409  root  4w  REG  253,0  112065  247 /var/log/messages [[email protected] log]# ls -al /proc/1409/fd/4 l-wx------. 1 root root 64 Jun 20 19:50 /proc/1409/fd/4 -> /var/log/messag

Ubuntu中没有/var/log/messages日志

在Ubuntu中没有/var/log/messages,Ubuntu中对应的应该是/etc/rsyslog.conf和rsyslogd. 解决方法:用vim打开/etc/rsyslog.d/50-default.conf文件末尾增加一行内容如下:*.info;mail.none;authpriv.none;cron.none /var/log/messages然后保存:按ESC,然后:wq:在重启系统 ,然后查看.var/log/messages就有了

过滤/var/log/messages中的net-snmp日志

Net-snmp的日志默认记录在/var/log/messages中,由于大多是snmp与远端主机的连接信息,且很多,影响了其他系统日志的查看,故可用本文的方法把snmp的日志从/var/log/messages中分离出来. 修改snmp-options参数实现: #vi /etc/sysconfig/snmpd.options OPTIONS="-LS2d -Lf /tmp/snmpd.log -p /var/run/snmpd.pid -a" 表示把snmp的日志输出到/tmp/s