In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail how to use the date command to display time in Linux. The content of the article is of high quality, so the editor shares it for you as a reference. I hope you will have some understanding of the relevant knowledge after reading this article.
The function of the date command is to display and set the system date and time
Command format:
Date [OPTION]... [+ FORMAT]
Date [- u |-- utc |-- universal] [MMDDhhmm [[CC] YY] [.ss]]
Parameters:
-d STRING: displays the date described by STRING
-s STRING: sets the date described by STRING
% Y year (for example, 1970, 2009, etc.)
The last two numbers of% y year (1988 is 88)
% m month (01.. 12)
% d the day ordinal of a month (01.. 31)
% H hours (00.23)
% I hours (01.. 12)
% k hours (0.23)
% l hours (1.. 12)
% p shows AM or PM
% M points (00.59)
% s seconds (00.59)
% r time (hh:mm:ss AM or PM), 12 hours
% T time (24-hour) (hh:mm:ss)
Format of X display time (H:%M:%S)
% x format of display date (mm/dd/yy)
% D date (mm/dd/yy)
% s seconds experienced since 00:00:00 on January 1, 1970
These are the ones commonly used, and the rest can be checked directly by man.
Example:
1. There is a special time at noon today. At 12:34:56, 2009-08 07, the following format can be used to display the format of 12, 34, 56, 7, 8, and 9. Where "-" can ignore the first "0".
Date +'% I _ amp% M _ ram% S _ r _ m _ r _ r _ y'
2. Set the year, month and day to 20090807 and the time to 00:00
Date-s 20090807
3. Set the time without changing the date
Date-s 16:02:23
4. Set the date and time
Date-s "20090807 16:02:23"
5. Check the specific time 100 days and 5 hours ago
Date-d "- 1 day 5 hour" + "Y-%m-%d H:%M:%S"
6. Check the time after 100 minutes
Date-d "+ 100 min" + "Y-%m-%d H:%M:%S"
7. Calculate the timestamp
Date-d 20090528 +% s
8. Restore timestamp
Date-d "1970-01-01 1243440000 sec GMT" + "F% T"
9. Update the system time online using NTP protocol
Ntpdate 210.72.145.44
On how to use the date command in Linux to display time is shared here, I hope that the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.