用Linux shell 计算两个时间差

用Linux shell 计算两个时间差,第1张

start=`date +%s -d "2011-11-28 15:55:37"`

end=`date +%s -d "2011-11-28 15:55:52"`

echo $(($end-$start))

这个前提是你能拿到开始和结束时间字串的基础上的。

如果你的日志文件输出格式是上述的话,还有个方法:

cat 日志文件 | awk '/^000/{

start=$2 " " $3

end=$4 " " $5

stm=mktime(gensub(/[:-]/, " ", "g", start))

etm=mktime(gensub(/[:-]/, " ", "g", end))

print $1 " - " etm-stm

}'

解决ssh连接提示Connection closed by xx某一天ssh连接外网的一个服务器A,突然连不了了,会提示:Connection closed by A的ip,连局域网内的一台服务器B却没有问题,(机子均为linux)服务器B上ssh连接A没有问题,但是无法用scp传文件给A,传输会一直挂住。改了各种配置文件,没有解决。输出信息如下: ssh -v [email protected] OpenSSH_6.6.1, OpenSSL 1.0.1k-fips 8 Jan 2015 debug1: Reading configuration data /etc/ssh/ssh_config debug1: /etc/ssh/ssh_config line 20: Applying options for * debug1: Connecting to 10.80.97.241 [10.80.97.241] port 22. debug1: Connection established. debug1: identity file /home/zengming/.ssh/id_rsa type -1 debug1: identity file /home/zengming/.ssh/id_rsa-cert type -1 debug1: identity file /home/zengming/.ssh/id_dsa type -1 debug1: identity file /home/zengming/.ssh/id_dsa-cert type -1 debug1: identity file /home/zengming/.ssh/id_ecdsa type -1 debug1: identity file /home/zengming/.ssh/id_ecdsa-cert type -1 debug1: identity file /home/zengming/.ssh/id_ed25519 type -1 debug1: identity file /home/zengming/.ssh/id_ed25519-cert type -1 debug1: Enabling compatibility mode for protocol 2.0 debug1: Local version string SSH-2.0-OpenSSH_6.6.1 debug1: Remote protocol version 2.0, remote software version OpenSSH_6.4 debug1: match: OpenSSH_6.4 pat OpenSSH* compat 0x04000000 debug1: SSH2_MSG_KEXINIT sent debug1: SSH2_MSG_KEXINIT received debug1: kex: server->client aes128-ctr [email protected] none debug1: kex: client->server aes128-ctr [email protected] none debug1: sending SSH2_MSG_KEX_ECDH_INIT debug1: expecting SSH2_MSG_KEX_ECDH_REPLY Connection closed by 10.80.97.241

《Linux内核精髓》(Munehiro IKEDA)电子书网盘下载免费在线阅读

链接:https://pan.baidu.com/s/1IkPuS83Etm-rDtH3TdgR3g

提取码:7p2m

书名:Linux内核精髓

作者:Munehiro IKEDA

译者:杨婷

豆瓣评分:7.0

出版社:机械工业出版社华章公司

出版年份:2013-3-1

页数:424

内容简介:

经过近20年的发展,Linux *** 作系统已经成为当今最成功的开源软件之一,使用广泛,影响深远。随着Linux *** 作系统功能的不断丰富和完善,Linux内核的源代码也从最初的几万行增加到如今的数百万行,庞大无比,对于Linux内核的研究者和开发者而言,要系统研究Linux内核绝非易事。鉴于此,本书选取了Linux内核的资源管理(CPU、内存、进程等)、文件系统、网络、虚拟化、省电、调试、概要分析、追踪、内核调整等核心主题进行了深入剖析和讲解,总结出了75个能使读者深刻理解Linux内核精髓的技巧和最佳实践。

作者简介

池田 宗广(Munehiro IKEDA),大学时代,亲眼看到X68000的gcc生成比主流编译器还要快好几倍的代码,因此开始确信免费软件/开源软件的可能性。此后,在历经咖啡店店员、生产技术人员、硬件工程师后,终于开始从事Linux内核开发。这个行业最吸引人的就是能够跨公司甚至跨国界与世界最优秀的技术人员进行交流。现居住在美国,爱好音乐演奏,当过鼓手,也当过主唱,最近几年一直在d贝斯。不管是作为技术人员还是贝斯手都喜欢做幕后工作,只不过天生就不喜欢半途而废。


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/yw/7343948.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-04
下一篇 2023-04-04

发表评论

登录后才能评论

评论列表(0条)

保存