Real-Time Clock Display in Linux

In Linux, you can use the watch command to display the time in real time.

命令格式如下:

watch -n 1 date

Using the “-n 1” option refreshes the command every second. The “date” command displays the current time. After running the command, the terminal window will show the current time in real-time and update every second.

To display the time in a specific format, you can use the parameters of the date command to specify the format. For example, to display the time in the format “YYYY-MM-DD HH:MM:SS”, you can use the following command:

watch -n 1 "date '+%Y-%m-%d %H:%M:%S'"

After running the above command, the terminal window will show the current time in the specified format in real-time.

bannerAds