linux system time to hardware time

        Linux system clock divided clock (System Clock) and the hardware clock (Real Time Clock, referred to as RTC). The system clock is the current in the Linux Kernel clock; the hardware on the motherboard clock is battery-powered clock, the hardware clock can be set in the BIOS. When Linux boots, the system clock to read the hardware clock is set, then the system clock will operate independently of the hardware clock.

        Linux shell command on the time of setting the date and hwclock there are two:

S3c6410 ARM embedded development board, Linux time settings:

        1. date - used to read or set the system time

        The current system time is set 2015/01/05 15:44:44

        # date -s "2015-01-05 15:44:44"

        2. hwclock - hardware to read or set the time

        # Hwclock -s hardware time synchronized to the system time

        # Hwclock -w to synchronize the system time to hardware time

General Linux system time:

 Linux all commands (including functions) are employed to set the system clock. In Linux, the command is used to view and set the clock mainly date, hwclock.

1、date

Name: date

Access: All users

Use:

date [-u] [-d datestr] [-s datestr] [--utc] [--universal] [--date=datestr] [--set=datestr] [--help] [--version] [+FORMAT] [MMDDhhmm[[CC]YY][.ss]]

Description:

can be used to display the date or date and time setting systems, in the display, the user can set the format to be displayed, the format is set to take a plus several markers, where the available list mark follows:
terms of time :

%: Print%

% N: the next line

% T: Tab

% H: h (00-23)

% I: h (01-12)

% K: hour (0-23)

% L: hour (1-12)

% M: min (00-59)

% P: display local AM or PM

% R: Direct display time (12-hour format hh: mm: ss [AP] M)

% S: 1970 Nian 1 Yue 1 Ri so far the number of seconds from 00:00:00 UTC

% S: seconds (00-60)

% T: Direct display time (24 hour)

% X: equivalent% H:% M:% S

% Z: Display time zone

Date of areas:

% A: day of the week (Sun-Sat)

% A: day of the week (Sunday-Saturday)

% B: month (Jan-Dec)

% B: month (January-December)

% C: direct display date and time

% D: day (01-31)

% D: direct display date (mm / dd / yy)

% H:% b with

% J: The first few days of the year (001-366)

% M: month (01-12)

% U: (the case with Sunday as the first day of the week) the first few weeks of the year (00-53)

% W: The first few days (0-6) of the week

% W: (the case with Monday as the first day of the week) the first few weeks of the year (00-53)

% X: direct display date (mm / dd / yy)

% Y: the last two digits of the year (00.99)

% Y: full year (0000-9999)

If not as the beginning of a plus sign, it means to set the time and time format MMDDhhmm [[CC] YY] [. Ss], where MM is the month, DD is the day, hh is hours, mm minutes, CC is first two digits of the year, YY is the year of two digits, ss is the number of seconds

Parameters:

-d datestr: datestr display time as set (non-system time)

--help: display auxiliary information

-s datestr: the system time is set in the time set datestr

-u: Displays the current Greenwich Mean Time

--version: show the version number

Examples:

After displaying the time skip, then

Display the current date: #date '+% T% n% D'

And display the number of days the month: date '+% B% d'

Display date and the set time (12:34:56): #date --date '12: 34: 56 '

Note: When you do not want meaningless 0 (for example, 1999/03/07) occurs, then the tag can be inserted in the - symbols, for example, date '+% - H:% - M:% - S' will 0 minutes and seconds to remove the meaningless, like the original 08:09:04 becomes 8: 9: 4. In addition, the person (such as root) only obtain permission to set the system time.

When you change the system time as root, remember to clock -w to write the CMOS system time, the system will continue to hold the latest time the correct value so the next reboot.

Example: Change the date and time

At the command line, type:

Date: Displays the current time Fri Aug 3 14:15:16 CST 2007

date -s: Modified manner as strings

You can modify only the date, not the modification time, enter: date -s 2007-08-03

Modify only time, enter: date -s 14:15:00

Meanwhile modification date and time, attention should double quotes, there is a space between the input date and time:

#date -s "2007-08-03 14:15:00"

2, view the hardware time

# hwclock

Set hardware time

# Hwclock -set -date = "07/07/06 10:19" (month / day / year hours: minutes: seconds)

3, time synchronization hardware and system time

According to the previous statement, restart the system, the hardware will read the system time to time, synchronization, but when not restart, the need to achieve synchronization with the hwclock command.

Hardware clock and system clock synchronization:

# Hwclock --hctosys (hc hardware on behalf of the time, sys represents the system time)

System clock and the hardware clock synchronization :( allow time to synchronize the system clock hardware)

Hwclock -systohc #
----------------
Disclaimer: This article is CSDN blogger "turn over downtown Beijing 'original article, follow the CC 4.0 BY-SA copyright agreements, please attach a reprint the original source link and this statement.
Original link: https: //blog.csdn.net/zuijinhaoma8/article/details/42423847

Guess you like

Origin www.cnblogs.com/sgh69/p/12050876.html