Common shell (1): shell gets the current time stamp of the system

1. Shell script as follows

current=`date "+%Y-%m-%d %H:%M:%S"`  
timeStamp=`date -d "$current" +%s`   
#将current转换为时间戳,精确到毫秒  
currentTimeStamp=$((timeStamp*1000+`date "+%N"`/1000000)) 
echo $currentTimeStamp

2. Operation effect

3. Note

this in timestamp way has a small error, the need to obtain precise timestamp refer to: https://blog.csdn.net/AQ931752921/article/details/85071221

Read More: