In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "order arrangement of time setting under Linux". In daily operation, I believe that many people have doubts about the command arrangement of time setting under Linux. The editor has consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts of "time setting command arrangement under Linux". Next, please follow the editor to study!
In a networked environment, it is a good habit to keep your Linux system time accurate. There are many services in Linux system that require the right time in order to work properly under networking conditions.
Let's take a look at the commands you can use to manage your machine time. In Linux, there are two ways to manage time: system time and hardware time.
System time is managed by system clock, and hardware time is managed by hardware clock.
To check your system time, date, and time zone, use the date command as follows.
The code is as follows:
Tecmint@tecmint ~ / Linux-Tricks $date
Wed Sep 9 12:25:40 IST 2015
Set the system time with date-s or date-set= "STRING" as shown below.
The code is as follows:
Tecmint@tecmint ~ / Linux-Tricks $sudo date-s "12:27:00"
Wed Sep 9 12:27:00 IST 2015
The code is as follows:
Tecmint@tecmint ~ / Linux-Tricks $sudo date-set= "12:27:00"
Wed Sep 9 12:27:00 IST 2015
You can also set the time and date as follows.
The code is as follows:
Tecmint@tecmint ~ / Linux-Tricks $sudo date 090912302015
Wed Sep 9 12:30:00 IST 2015
Use the cal command to view the current date from the calendar.
The code is as follows:
Tecmint@tecmint ~ / Linux-Tricks $cal
September 2015
Su Mo Tu We Th Fr Sa
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30
Use the hwclock command to view the hardware clock time.
The code is as follows:
Tecmint@tecmint ~ / Linux-Tricks $sudo hwclock
Wednesday 09 September 2015 06:02:58 PM IST-0.200081 seconds
To set the hardware clock time, use the hwclock-set-date= "STRING" command as follows.
The code is as follows:
Tecmint@tecmint ~ / Linux-Tricks $sudo hwclock-- set-- date= "09swap 09Universe 12:33:00"
Tecmint@tecmint ~ / Linux-Tricks $sudo hwclock
Wednesday 09 September 2015 12:33:11 PM IST-0.891163 seconds
The system time is set by the hardware clock time at startup, and when the system is shut down, the hardware time is reset to the system time.
So when you look at the system time and the hardware time, they are the same unless you change the system time. When your CMOS is running low, the hardware time may be incorrect.
You can also set the system time using the time of the hardware clock as follows.
The code is as follows:
$sudo hwclock-hctosys
You can also set the hardware clock time with the system clock time as follows.
The code is as follows:
$sudo hwclock-systohc
To see how long your Linux system has been running, use the uptime command.
The code is as follows:
Tecmint@tecmint ~ / Linux-Tricks $uptime
12:36:27 up 1:43, 2 users, load average: 1.39, 1.34, 1.45
The code is as follows:
Tecmint@tecmint ~ / Linux-Tricks $uptime-p
Up 1 hour, 43 minutes
The code is as follows:
Tecmint@tecmint ~ / Linux-Tricks $uptime-s
2015-09-09 10:52:47
Linux command date date time and Unix timestamp convert each other
a. Convert a date to a Unix timestamp
Represents the current time as a Unix timestamp:
The code is as follows:
Date +% s
The output is as follows:
1361542433
The specified date of the conversion is a Unix timestamp:
The code is as follows:
Date-d '2013-2-22 22 14' +% s
The output is as follows:
1361542440B. Convert Unix timestamp to date time
Do not specify the format of the date time:
The code is as follows:
Date-d @ 1361542596
The output is as follows:
Fri Feb 22 22:16:36 CST 2013 conversion of the specified date format:
The code is as follows:
Date-d @ 1361542596 + "Y-%m-%d H:%M:%S"
The output is as follows:
2013-02-22 22:16:36
At this point, the study of "sorting out the relevant commands for time setting under Linux" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.