Linux system date Time Settings View command

Source: Internet
Author: User
Tags set time time and date

1. Date Order

The function of the date command is to display and set the system date and time.
The general format for this command is: date [options] Displays the time format (beginning with +, followed by formatting)
Date set time format
The meanings of the options in the command are:
-D datestr,--date DATESTR displays the date described by datestr
-S Datestr,--set datestr set datestr description of the date
-U,--universal Show or set Universal Time

The code is as follows Copy Code

View system time

# date

Set system time

# date--set "07/07/06 10:19" (Month/day/year: minutes: SEC)

2, Hwclock/clock

Syntax: Hwclock [--adjust][--debug][--directisa][--hctosys][--show][--systohc][--test]
[--UTC] [--version] [--set--date=< Date and time]

Supplemental explanation: In Linux has the hardware clock and the system clock and so on two kinds of clocks. The hardware clock refers to the clock device on the motherboard, which is usually the clock set in the BIOS screen. The system clock refers to the clock in the kernel. When Linux starts, the system clock reads the hardware clock setting, and the system clock is operated independently. All Linux related instructions and functions are set to read the system clock.

View hardware Time

The code is as follows Copy Code

# Hwclock--show

Or

# clock--show


Set Hardware time

The code is as follows Copy Code

# Hwclock--set--date= "07/07/06 10:19" (Month/day/year: minutes: SEC)

Or

# clock--set--date= "07/07/06 10:19" (Month/day/year: minutes: SEC)

3, hardware time and system time synchronization


According to the previous version, reboot the system, the hardware time will read the system time, to achieve synchronization, but without restarting, you need to use the Hwclock or clock command to achieve synchronization.

The hardware clock synchronizes with the system clock:

The code is as follows Copy Code

# Hwclock--hctosys
(HC represents the hardware time, SYS represents the system time), or


# clock--hctosys

system clock and Hardware clock sync:

# Hwclock--SYSTOHC

Or

# clock--SYSTOHC

Finally, attach the Linux date command parameters

Time Domain
% H hours (00. 23)
% I-hour (01. 12)
% K hours (0. 23)
% l hour (1. 12)
% M minute (00. 59)
% p displays am or PM
% R Time (Hh:mm:ss am or PM), 12 hours
% s number of seconds from January 1, 1970 00:00:00 to current experience
% S sec (00. 59)
% T Time (24-hour system) (HH:MM:SS)
% X shows the format of the time (%h:%m:%s)
% Z time zone Date field
% a weekday abbreviation (Sun.. Sat)
% A week's full name (Sunday). Saturday)
The abbreviation of the% B-month. DEC)
The full name of the% B-month (January). December)
% c date and time (Mon Nov 8 14:12:46 CST 1999)
% d One months of the first day (01. 31)
% D Date (MM/DD/YY)
% h and%b options are the same
% J The first day of the year (001. 366)
% m month (01. 12)
% W one week of the first day (0 for Sunday)
% W The first few weeks of the year (00. 53, Monday for the first day)
% x shows the format of the date (MM/DD/YY)
The last two digits of the Y-year (1999 is 99)
% Y year (for example: 1970,1996 etc.)


hwclock Parameters:

--adjust Hwclock each time the hardware clock is changed, it is recorded in the/etc/adjtime file. The--adjust parameter allows the Hwclock to estimate the hardware clock deviation based on previous records and use it to correct the current hardware clock.
--DEBUG displays detailed information when Hwclock executes.
--directisa hwclock preset To access hardware clocks from/DEV/RTC devices. If it is not accessible, this parameter can be used to access the hardware clock directly with the I/O instruction.

The

--hctosys adjusts the system clock to match the current hardware clock.
--set--date=< Date and time > Set hardware clock. The
--show displays the time and date of the hardware clock. The
--SYSTOHC adjusts the hardware clock to match the current system clock. The
--test only tests the program and does not actually change the hardware clock.
--utc To use GMT, add this parameter, Hwclock will perform the work of the conversion. The
--version displays version information.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.