In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article shows you how to make OS system time changes, concise and easy to understand, absolutely can make your eyes shine, through the detailed introduction of this article I hope you can gain something.
[root@srv14 ~]# man date
[root@srv14 ~]# date -s 112212302011
date: invalid date `112212302011'
[root@srv14 ~]#
[root@srv14 ~]# date
Tue Nov 22 11:54:53 CST 2011
[root@srv14 ~]# man date
[root@srv14 ~]# date -s "20180403 11:04:05"
Tue Nov 22 12:37:48 CST 2011
[root@srv14 ~]#
[root@srv14 ~]#
[root@srv14 ~]#
[root@srv14 ~]# date
Tue Nov 22 12:37:50 CST 2011
[root@srv14 ~]# hwclock
Tue 22 Nov 2011 12:03:16 PM CST -0.696725 seconds
[root@srv14 ~]# clock --hctosys
[root@srv14 ~]# hwclock
Tue 22 Nov 2011 12:05:08 PM CST -0.880236 seconds
[root@srv14 ~]# date
Tue Nov 22 12:05:09 CST 2011
[root@srv14 ~]#
================
Example 1:
#date //Show the current date
#date -s //Set the current time. Only root permission can be set. Others can only be viewed.
#date -s 20061010 //Set to 20061010, which sets the specific time to null 00:00:00
#date -s 12:23:23 //Set specific time, do not change the date
#date -s "12:12:23 2006-10-10″ //This allows you to set all times
CST: China Standard Time, this interpretation may be for Red Hat Linux.
UTC: Coordinated Universal Time, also known as Universal Standard Time, abbreviated UTC, from English International Time/French Coordinated Time "Universal Time/Temps Cordonné". The time difference between UTC and the mainland of China, Hong Kong, Macau, Taiwan, Mongolia, Singapore, Malaysia, Philippines and Western Australia is +8, which is UTC+8.
GMT: Greenwich Mean Time (GMT) refers to the standard time at the Royal Greenwich Observatory in suburban London, England, because the prime meridian is defined at the meridian that passes there.
After setting the system time, you also need to synchronize to the hardware clock
# clock --systohc
Hardware clock synchronization with system clock:
# hwclock --hctosys
or
# clock --hctosys
In the above command, --hctosys stands for Hardware Clock to SYStem clock.
System clock and hardware clock synchronization:
# hwclock --systohc
or
# clock --systohc
Example 2:
Displays the time in the specified format.
$ date ‘+This date now is =>%x ,time is now =>%X ,thank you ! '
This date now is =>11/12/99 ,time is now =>17:53:01 ,thank you !
Displays the current time in a predetermined format.
# date
Fri Nov 26 15:20:18 CST 1999
Set the time to 14:36 p. M.
# date -s 14:36:00
Fri Nov 26 14:15:00 CST 1999
Set to November 28, 1999.
# date -s 991128
Sun Nov 28 00:00:00 CST 1999
Set a day ago
date --date "1 days ago" +"%Y-%m-%d"
Date Command Parameters Tips
Because Linux is vague about the man date -d parameter, the following example is given:
# -d, --date=STRING display time described by STRING, not `now'
For Linux
[root@linuxso.com ~ ]# date -d next-day +%Y%m%d
20060328
[root@linuxso.com ~ ]# date -d last-day +%Y%m%d
20060326
[root@linuxso.com ~ ]# date -d yesterday +%Y%m%d
20060326
[root@linuxso.com ~ ]# date -d tomorrow +%Y%m%d
20060328
[root@linuxso.com ~ ]# date -d last-month +%Y%m
200602
[root@linuxso.com ~ ]# date -d next-month +%Y%m
200604
[root@linuxso.com ~ ]# date -d next-year +%Y
2007
------------------------------------------
FreeBSD is different; for example:
For FreeBSD
[root@linuxso.com ~]# date -v -1d +%Y%m%d
20060326
[root@linuxso.com ~]# date -v -1m +%Y%m%d
20060227
[root@linuxso.com ~]# date -v -1y +%Y%m%d
20050327
Example 3:
In linux environment to get a few days ago period just use
date -d "x days ago" +%Y%m%d
x is replaced by a number. If you need to write a positive number directly a few days ago, you can write a negative number directly if you want a few days later.
date -d "x weeks ago" +%Y%m%d
x is replaced by a number, if you need a few weeks ago, write a positive number directly, if you want a few weeks later, write a negative number directly.
date -d "x years ago" +%Y%m%d
x is replaced by a number. If you need to write a positive number directly a few years ago, you can write a negative number directly if you want a date a few years later.
Consider the following example:
[root@linuxso.com ~]# date +%Y%m%d
20100107
It has today's date 20100107.
[root@linuxso.com ~]# date -d "2 days ago" +%Y%m%d
20100105
dated two days ago.
[root@linuxso.com ~]# date -d "4 days ago" +%Y%m%d
20100103
It's dated four days ago.
[root@linuxso.com ~]# date -d "-1 days ago" +%Y%m%d
20100108
It's a day from now.
[root@linuxso.com ~]# date -d "-2 days ago" +%Y%m%d
20100109
It's dated two days from now.
[root@linuxso.com ~]# date -d "1 week ago" +%Y%m%d
20091231
It's dated a week ago.
[root@linuxso.com ~]# date -d "1 year ago" +%Y%m%d
20090107
The above is how to modify OS system time. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserves, please pay attention to the industry information channel.
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.