平时写的各种linux shell脚本
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
459 B

#!/bin/bash
##### CentOS一键同步时间 #####
##### Author:xiaoz.me #####
##### Update:2019-07-27 #####
#安装ntpdate
yum -y install ntpdate
#设置时区
timedatectl set-local-rtc 1
timedatectl set-timezone Asia/Shanghai
#同步时间
ntpdate -u pool.ntp.org
ntpd=(`which ntpdate`)
#定时任务
echo "*/20 * * * * ${ntpd} pool.ntp.org > /dev/null 2>&1" >> /var/spool/cron/root
systemctl reload crond
echo "同步成功,当前时间:" date