Skip to content

Instantly share code, notes, and snippets.

@huobazi
Created May 24, 2021 03:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save huobazi/c43ad677a93f317612a82cbf978f0874 to your computer and use it in GitHub Desktop.
Save huobazi/c43ad677a93f317612a82cbf978f0874 to your computer and use it in GitHub Desktop.
服务器同步网络时间

同步网络时间

#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
#!/bin/bash
#同步网络时间
echo “同步网络时间中…”
apt-get install -y ntpdate
ntpdate -u cn.pool.ntp.org
#ntpdate time.nuri.net
hwclock -w
mv /etc/localtime /etc/localtime.bak
ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
date
echo "----------------------------------------------------------------------------"
endDate=`date +"%Y-%m-%d %H:%M:%S"`
echo "★[$endDate] Successful"
echo "----------------------------------------------------------------------------"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment