View and modify CentOS time

Source: Internet
Author: User
Tags time zones

View and modify CentOS time

1. view and modify the Linux time zone and time


I. Viewing and modifying linux time zones


1. view the current time zone
Date-R

2. Modify the time zone
Method 1:
Tzselect

Method 2:
Limited to RedHat Linux and CentOS
Timeconfig

Method 3:
Applicable to Debian
Dpkg-reconfigure tzdata

3. Copy the corresponding time zone file, replace the system time zone file, or create a link file.
Cp/usr/share/zoneinfo/$ main Time Zone/$ Time Zone/etc/localtime


Available in China:
Cp/usr/share/zoneinfo/Asia/Shanghai/etc/localtime

Ii. Viewing and modifying linux time


1. view the time and date
Date


2. Set the time and date
Set the system date to June 10, 1996.
Data-s 06/22/96


Set the system time to 01:52:00 P.M..
Date-s 13:52:00


3. Write the current time and date to the BIOS to prevent failure after restart
Hwclock-w

Iii. Scheduled synchronization time


* ***/Usr/sbin/ntpdate 210.72.145.44>/dev/null 2> & 1

In Linux, the commands used for clock viewing and setting mainly include date, hwclock, and clock.
Among them, clock and hwclock use similar, just use one line, but clock commands not only support x86 hardware system, but also support Alpha hardware system.

View the Linux system time:
Date

[Html] view plaincopyprint?
  1. Hwclock-hctosys
  2. # Or
  3. Clock-hctosys


Linux system modification time:
Date-s (followed by Time)

View Linux hardware time:

Java code
[Html] view plaincopyprint?
  1. Hwclock
  2. # Or
  3. Clock
  4. # Or
  5. Hwclock-show
  6. # Or
  7. Clock-show

Linux hardware modification time:

C code

[Csharp] view plaincopyprint?
  1. Hwclock-set-date
  2. # Or
  3. Clock-set-date
Synchronize the system time with the hardware clock:

C code

[Html] view plaincopyprint?
  1. Hwclock-hctosys
  2. # Or
  3. Clock-hctosys
On the contrary, synchronize the hardware clock with the system time:

C code

[Html] view plaincopyprint?
  1. Hwclock-systohc
  2. # Or
  3. Clock-systohc

Let the system synchronize the hardware time every ten minutes.

C code
[Html] view plaincopyprint?
  1. [Hqw @ localhostroot] $ vi/etc/crontab
  2. SHELL =/bin/bash
  3. PATH =/sbin:/bin:/usr/sbin:/usr/bin
  4. MAILTO = root
  5. HOME =/
  6. # Run-parts
  7. 01 ***** rootrun-parts/etc/cron. hourly
  8. 024 *** rootrun-parts/etc/cron. daily
  9. 224 ** 0rootrun-parts/etc/cron. weekly
  10. 4241 ** rootrun-parts/etc/cron. monthly
  11. */10 * roothwclock -- hctosys # Add this row and run hwclock -- hctosys every 10 minutes.

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.