# cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
修改为中国的东八区
# vi /etc/sysconfig/clock
ZONE="Asia/Shanghai"
UTC=false
ARC=false
日期设定:
# date -s 2008/05/06
# date -s 18:40:00
hwclock [-rw]
-r:查看现有BIOS时间,默认为-r参数
-w:将现在的linux系统时间写入BIOS中
# hwclock
Tue 06 May 2008 03:49:37 PM CST -0.039646 seconds
# clock -w
方法1. 开机的时候自动网络校时:
vi /etc/rc.d/rc.local
/usr/sbin/ntpdate -u 192.168.0.2 192.168.0.3 192.168.0.4; /sbin/hwclock -w
crontab格式如下:
# For details see man 4 crontabs
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * command to be executed
代码:
00 11 * * * root ntpdate 210.72.145.44
每天11点与中国国家授时中心同步时间
每天11点与中国国家授时中心同步时间
当然前提是
apt-get install ntpdate
00 11 * * * root ntpdate us.pool.ntp.org
2、使用命令crontab -e
crontab -e
10 5 * * * root ntpdate us.pool.ntp.org;hwclock -w
这样每天5:10自动进行网络校时,并同时更新BIOS的时间