#!/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