2018年12月28日 星期五

freebsd 設定 NTP 自動校時

方法一
1. 編輯rc.conf
>ee /etc/rc.conf

ntpd_enable="YES"

2.編輯ntp.conf
>ee /etc/ntp.conf

server  168.95.1.1     iburst

restrict default ignore
restrict -6 default ignore

restrict 168.95.1.1

#以上為本機校時,加入下面則開放該網段可連線校時
restrict 192.168.1.0 mask 255.255.255.0 nomodify

3.啟動ntpd
>/etc/rc.d/ntpd start

==================================================

方法二
編輯 crontab
>ee /etc/crontab

#每天四點校時
0 4 * * * root /usr/sbin/ntpdate time.stdtime.gov.tw

==================================================

方法三
1.新增daily執行script
>ee /etc/periodic/daily/600.ntpdate
#!/bin/sh
echo
echo '主機校時'
/usr/sbin/ntpdate time.stdtime.gov.tw

2.更改600.ntpdate權限
>chmod +x 600.ntpdate

沒有留言: