[Reprint] linux system time setting

Source: Internet
Author: User
Tags iso 8601 iso 8601 format month name rfc
We generally use the "date-s" command to modify the system time. For example, the command to set the system time to 20066-October 19 is as follows.

Original article address: linux system time setup author: Lazy Girl style

We generally use the "date-s" command to modify the system time. For example, the command to set the system time to 20066-October 19 is as follows.
# Date-s 19/10/2006
The command to set the system time to 01:12:00 P.M. is as follows.
# Date-s 13:12:00

---- NOTE: This is about the system time, which is maintained by the operating system in linux.
---- When the system is started, the Linux operating system reads the time from CMOS to the system time variable. later, the modification time is implemented by modifying the system time. To maintain the consistency between the system time and the CMOS time, Linux writes the system time to the CMOS at intervals. Because the synchronization is performed at intervals (about 11 minutes), after we execute date-s, if the machine is restarted immediately, the modification time may not be written to CMOS, this is the cause of the problem. To make sure the modification takes effect, run the following command.

---- # Clock-w

---- This command forces the system time to be written into CMOS.



[Root @ mail ~] # Date -- help
Usage: date [OPTION]... [+ FORMAT]
Or: date [-u | -- utc | -- universal] [MMDDhhmm [[CC] YY] [. ss]
Display the current time in the given FORMAT, or set the system date.

-D, -- date = STRING display time described by STRING, not 'now'
-F, -- file = DATEFILE like -- date once for each line of DATEFILE
-ITIMESPEC, -- ISO-8601 [= TIMESPEC] output date/time in ISO 8601 format.
TIMESPEC = 'Date' for date only,
'Urs', 'minutes ', or 'seconds' for date and
Time to the indicated precision.
-- ISO-8601 without TIMESPEC defaults to 'date '.
-R, -- reference = FILE display the last modification time of FILE
-R, -- rfc-2822 output RFC-2822 compliant date string
-S, -- set = STRING set time described by STRING
-U, -- utc, -- universal print or set Coordinated Universal Time
-- Help: displays the help information and leaves
-- Version: displays the version information and leaves.

FORMAT controls the output. The only valid option for the second form
Specifies Coordinated Universal Time. Interpreted sequences are:

% A literal %
% A locale's abbreviated weekday name (Sun .. Sat)
% A locale's full weekday name, variable length (Sunday... Saturday)
% B locale's abbreviated month name (Jan .. Dec)
% B locale's full month name, variable length (January... December)
% C locale's date and time (Sat Nov 04 12:02:33 EST 1989)
% C century (year divided by 100 and truncated to an integer) [00-99]
% D day of month (01 .. 31)
% D date (mm/dd/yy)
% E day of month, blank padded (1 .. 31)
% F same as % Y-% m-% d
% G the 2-digit year corresponding to the % V week number
% G the 4-digit year corresponding to the % V week number
% H same as % B
% H hour (00 .. 23)
% I hour (01 .. 12)
% J day of year (001. 366)
% K hour (0 .. 23)
% L hour (1 .. 12)
% M month (01 .. 12)
% M minute (00 .. 59)
% N a newline
% N nanoseconds (000000000 .. 999999999)
% P locale's upper case AM or PM indicator (blank in memory locales)
% P locale's lower case am or pm indicator (blank in lower locales)
% R time, 12-hour (hh: mm: ss [AP] M)
% R time, 24-hour (hh: mm)
% S seconds since '00: 00: 00 1970-01-01 UTC '(a GNU extension)
% S second (00 .. 60); the 60 is necessary to accommodate a leap second
% T a horizontal tab
% T time, 24-hour (hh: mm: ss)
% U day of week (1 .. 7); 1 represents Monday
% U week number of year with Sunday as first day of week (00 .. 53)
% V week number of year with Monday as first day of week (01 .. 53)
% W day of week (0 .. 6); 0 represents Sunday
% W week number of year with Monday as first day of week (00 .. 53)
% X locale's date representation (mm/dd/yy)
% X locale's time representation (% H: % M: % s)
% Y last two digits of year (00 .. 99)
% Y year (1970 ...)
% Z RFC-2822 style numeric timezone (-0500) (a nonstandard extension)
% Z time zone (e.g., EDT), or nothing if no time zone is determinable

By default, date pads numeric fields with zeroes. GNU date recognizes
The following modifiers between '%' and a numeric directive.

'-' (Hyphen) do not pad the field
'_' (Underscore) pad the field with spaces

Report bugs .

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.