shell计算时间差

时间:2021-06-10 22:45:44   收藏:0   阅读:40
#!/bin/bash
current1=`date "+%Y-%m-%d %H:%M:%S"`

start_time=`date -d "$current1" +%s`

sleep 5s

current2=`date "+%Y-%m-%d %H:%M:%S"`
end_time=`date -d "$current2" +%s`

#相减算差值

time_query=`expr $end_time - $start_time`

echo $time_query

  

原文:https://www.cnblogs.com/to-here/p/14872563.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!