#!/bin/bash  
  
NTP_SERVER="ntp1.aliyun.com"  
  
if ! command -v ntpdate &> /dev/null  
then  
    echo "ntpdate 没有安装，请先安装它。"  
    exit 1  
fi  
  
ntpdate $NTP_SERVER  
  
if [ $? -eq 0 ]; then  
    echo "时间已成功同步到 $NTP_SERVER"  
    hwclock --systohc 
else  
    echo "时间同步失败"  
fi