#!/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
2023-10-16 08:53:52
#!/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