Linux Automatic Update system and manual view, modify system time

Source: Internet
Author: User
Tags time and date

When we installed a new CentOS system in the virtual machine, although in the installation of the NTP set up the selection of Shanghai, but entered the system, enter the date command, check the system time and the current time is not the same, we can use the above method to view, automatically update and modify the system time

To view the system time:

[Email protected] ~]# Datesat Mar 00:47:59 CST 2017


I. Linux Auto-update Time

to update using the ntpdate command :

[Email protected] ~]# ntpdate time.nist.gov24 Mar 16:52:03 ntpdate[2694]: Step time server 216.229.0.179 offset-28803.12 4630 Sec[[email protected] ~]# Datefri Mar 16:52:29 CST 2017


You can also use Microsoft's time synchronization server for time synchronization

[Email protected] ~]# ntpdate time.windows.com24 Mar 16:53:35 ntpdate[2697]: Adjust time server 52.178.223.23 offset 0.04 0309 sec[[email protected] ~]# Datefri Mar 16:53:39 CST 2017


set up Linux automatically synchronize time every 5 minutes Server for time synchronization

[[email protected] ~]# echo ' #time sync by mrxiong2017-03-24 ' >/var/spool/cron/root[[email protected] ~]# echo ' */5**** /sbin/ntpdate time.nist.gov >/dev/null 2>&1 ' >>/var/spool/cron/root[[email protected] ~]# cat/var/ Spool/cron/root #time Sync by mrxiong2017-03-24*/5****/sbin/ntpdate time.nist.gov >/dev/null 2>&1

View scheduled tasks to see if they've been set up successfully

[[email protected] ~]# crontab-l#time sync by mrxiong2017-03-24*/5****/sbin/ntpdate time.nist.gov >/dev/null 2>& Amp;1


This enables the updating of Linux system time. However, because the system time and hardware clock is not consistent, in order to synchronize immediately, you can enter a command

Hwclock-w

Write system time to BIOS immediately

Or

Hwclock--hctosys

Synchronizing the system time with the hardware clock


two. Linux Manually change the time to view the time of the system or hardware clock

Use the date command for related time viewing and modification operations

1) input

Date

Can view the time of the current system

Hwclock--show

The current time of the hardware clock can be viewed


2) Input:

Date-s 20100816 12:56:00

You can set a specific time and date (note, however, you must enter the Linux system as root, otherwise you do not have permission)

After modifying the system time, in order to synchronize the system time with the hardware clock, you must enter:

Hwclock-w

Write system time to BIOS

Or

Hwclock--hctosys


If the company has more than one client, you can set up two time servers, frame composition ideas are as follows:

650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M02/8F/26/wKioL1jU4CCgjJRNAABz123WRLY396.png "title=" 4.png "alt=" Wkiol1ju4ccgjjrnaabz123wrly396.png "/>

This article is from the "Mr.xiong's OPS log" blog, so be sure to keep this source http://mrxiong2017.blog.51cto.com/12559394/1910098

Linux Automatic Update system and manual view, modify system time

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.