##使用crontab定时服务,定时同步网络时间
- crontab -e
- 添加新任务
#!/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
0-59/10 * * * * /usr/sbin/ntpdate us.pool.ntp.org | logger -t NTP
##重启crond服务
ubuntu: sudo service cron restart
centos:sudo service crond restart
##设置时区
ubuntu:tzselect
centos:timeconfig
将设置结果保存到根目录的.profile文件中,退出重新登录,即可。
echo "TZ='Asia/Shanghai'; export TZ" >> ~/.profile