Date and time commands, set computer hardware RTC time

date command

**

Get system time

**: date
Syntax 1: date, output: Insert picture description here
Syntax 2: date "+% F" (equivalent to date "+% Y-% m-% d") Insert picture description here
Syntax 3: date "+% F% T" (etc. Price on date + "+% Y-% m-% d% H:% M:% S")
Insert picture description here
Syntax 4: Get a time before or after (backup)
date -d "-1 day" "+% Y -% m-% d% H:% M:% S "
optional values: + (after),-(before)
optional values ​​of units: day (day), month (month), year (year)
Insert picture description here

hwclock command (server hardware time)

Function: Obtain computer hardware RTC time
Insert picture description here

Set system time

date -s "2012-12-12 10:10:10", -s means to set the system time (set)
Insert picture description here
Option 1: hwclock -w, save the Linux system time to the hardware RTC (applicable to hardware time error, set After the system time, synchronize the system time to the hardware time)
Insert picture description here
Option two: hwclock -s, save the time in RTC to the Linux system time (applicable to system time error, directly recover from the hardware time)
Insert picture description here

Published 21 original articles · liked 0 · visits 580

Guess you like

Origin blog.csdn.net/u014270566/article/details/104257394