I know that gettimeofday() is a nice API. But how to get the number of seconds with milliseconds since the epoch time? You can get the time at nano-seconds level (although it is not guaranteed that the last digits are accurate) by:date +%s.%N Related posts:Setting sbt log level at the command line How to delete a specific line from a text file in command line on Linux? How to set the replication factor for one file when it is uploaded by `hdfs dfs -put` command line in HDFS? How to convert .pptx slides to .jpg or .png images on Linux in command line? How to convert a .docx .doc MS Word file to pdf in command line on Linux How to set Google Chrome’s proxy settings in command line on Linux? How to make Emacs run in command line by default? How to search history commands very effectively in bash shell command line?