The date command can be used to display and modify the system datetime, noting that it is not a time command.
1. Enter date at the command line to display the current time
[[Email protected] logs]# Date
Sat Nov 00:00:02 CST 2014
2. Enter the date-s date on the command line
Only modified date, not modified time
[Email protected] logs]# date-s 2014-11-21
Fri 00:00:00 CST 2014
3. Enter date-s time at the command line
Modify time only, no date modified
[Email protected] logs]# date-s 14:15:00
Fri 14:15:00 CST 2014
4, in the command line input date-s also modify the date time, note to add double quotation marks, the date and time there is a space
[[email protected] logs] #date-S "2007-08-03 14:15:00"
Note that this is the system time that is maintained by the Linux operating system. when the system starts, theLinux operating system reads the time from the CMOS into the system time variable, and the later modification time is realized by modifying the system time. To keep the system time consistent with the CMOS time,Linux writes the system time to CMOS at every time. Since this synchronization takes place at intervals (about 11 minutes), if the machine is re-started immediately after we execute the DATE-S, the modification time may not be written to the CMOS, which is the cause of the problem. You can execute the following command if you want to make sure that the changes take effect. [[email protected] logs]#clock-w This command forces the system time to be written to the CMOS 。
Linux Command Learning-date