LIunx next date command

Linux system clock divided clock (System Clock) and hardware (Real Time Clock, referred to as RTC) clock. Refers to the current system clock is the clock in Linux Kernel, and the hardware on the motherboard clock is battery-powered clock, the hardware clock can be set in the BIOS. When Linux boots, to read the hardware clock is the system clock is set, then the system clock will operate independent of the hardware.
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 =] [- [. ss] set = datestr] [--help] [--version] [+ FORMAT] [MMDDhhmm [[CC] YY]]
Description:
dATE can be used to display or set the system date and time, in the display the user can set the format to be displayed, the format is set to the number of contact plus a mark, where the available list mark as follows:
time aspects:
%:% print
% n-: next line
% T: Tab
% H: hour (00-23)
% the I: h (01-12)
% K: hour (0-23)
% L: hour (1-12)
% M: min (00-59)
% P: AM local display or the PM
% R & lt: Direct display time (12-hour clock format HH: mm: SS [the AP] M)
% S: from January 1, 1970 00:00:00 UTC seconds to date
% S: seconds (00-60)
% T: direct display time (24 hour)
% X-: equivalent H%:% M:% S
% the Z: display time zone
date aspects:
% A: week (the Sun-Sat)
% A: week (the Sunday-Saturday)
% B: month (Jan-On Dec)
% B: month (January-December)
% C: direct display date and time
% d: day (01-31)
% D: direct display date (mm / dd / YY)
% H: with B%
% J: the first day of the year (001-366)
% m: (01-12 )
% U: the case of the first few weeks of the year (00-53) (with Sunday as the first day of the week)
% w: the first few days of the week (0-6)
% W: the first of the year weeks (00-53) (in the first day of the week Monday to case)
% X: direct display date (mm / dd / yy)
% y: the last two digits of the year (00.99)
% the 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 for the first two digits of the year, YY is the year of two digits, ss is the number of seconds
parameters:
-d datestr: in the display datestr set time (non-system time)
--help: display auxiliary information
-s datestr: the system time is set datestr set in the time
-u: displays the current GMT
--version: show the version number
example :
after displaying the skip time, and then
display the current date: #date '+% T% n % D'
shows the number of days of the month: date '+% B% d '
display date and the set time (12:34:56): #date --date '12: 34: 56 '
Note: when (for example, 1999/03/07) you do not want to appear meaningless 0, can be inserted in the tag - the symbol, for example, date' +% - H:% - M:% - S ' when the minutes and seconds will remove meaningless to 0, 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.
Examples: change date and time
at the command line:
a Date:-Aug. 3 shows the current time is 14:15:16 CST 2007 Fri
DATE -s: Modified manner as strings
can modify only the date, time does not modify, enter: date -s 2007 -08-03
only modification time, enter: date -s 14:15:00
simultaneous 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 to view the hardware time
# hwclock
set the hardware time
# hwclock -set -date =" 07/07/06 10:19 "( month / day / year hours: minutes: seconds)
3, hardware and system time synchronization of time
in accordance with 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 represent hardware time, sys represents the system time)
system hardware clock and system clock synchronization :( allow time to synchronize the hardware clock)
# hwclock -systohc

Guess you like

Origin blog.csdn.net/showmessage0804/article/details/38587491