Synchronizing Linux system time scripts

Source: Internet
Author: User
Share a synchronization Linux system time D script, you can automatically set the system time zone for the East Eight, and synchronize the system, when the Ntpdate synchronization failure will try to synchronize with Rdate, time server us.ntp.org.cn and time.nist.gov can replace their usual

#!/bin/bash[ "`rpm -qa | egrep ^rdate`" ] || yum -y install rdate > /dev/null 2>&1tz=`date -R | awk ‘{print $NF}‘`if [ $tz != "+0800" ]   then       \cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime        echo ZONE=\"Asia/Shanghai\" > /etc/sysconfig/clockfi/usr/sbin/ntpdate us.ntp.org.cnif [ $? != 0 ]   then      /usr/bin/rdate -s time.nist.govfi/sbin/hwclock -w

Combined with Cron to make a task plan, you can periodically automatically synchronize the system time.

Synchronizing Linux system time scripts

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.