自动调整linux系统时间和时区与Int…
来源:互联网 发布:天下网络卡盟 编辑:程序博客网 时间:2024/05/27 14:14
调整linux系统时间和时区与Internet时间同步
一、修改时区:
# cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
修改为中国的东八区
# vi /etc/sysconfig/clock
ZONE="Asia/Shanghai"
UTC=false
ARC=false
# 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 2008/05/06
时间设定:
# date -s 18:40:00
# date -s 18:40:00
查看硬件时间(BIOS的):
hwclock[-rw]
-r:查看现有BIOS时间,默认为-r参数
-w:将现在的linux系统时间写入BIOS中
# hwclock
Tue 06 May 2008 03:49:37 PM CST
同步BIOS时钟,强制把系统时间写入CMOS:
# clock -w
# clock -w
三、实现Internet时间同步(这里可以忽略上面两步)
方法1. 开机的时候自动网络校时:
vi/etc/rc.d/rc.local
/usr/sbin/ntpdate -u 192.168.0.2 192.168.0.3192.168.0.4; /sbin/hwclock-w
方法1. 开机的时候自动网络校时:
方法2. 设定计划任务
crontab格式如下:
# For details see man 4 crontabs
crontab格式如下:
# For details see man 4 crontabs
# Example of job definition:
# .---------------- 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) ORsun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * command to beexecuted
# .---------------- minute (0 - 59)
# |
# |
# |
# |
# |
# *
设定crontab计划任务也有两种方式:
1、写在/etc/crontab里
代码:
00 11 * * * root ntpdate 210.72.145.44
每天11点与中国国家授时中心同步时间
每天11点与中国国家授时中心同步时间
当然前提是
apt-get install ntpdate
代码:
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的时间
00 11 * * * root ntpdate us.pool.ntp.org
2、使用命令crontab -e
crontab -e
0 0
- 自动调整linux系统时间和时区与Int…
- 自动调整linux系统时间和时区与Internet时间同步
- 自动调整linux系统时间和时区与Internet时间同步
- 自动调整linux系统时间和时区与Internet时间同步
- 自动调整linux系统时间和时区与Internet时间同步
- 自动调整linux系统时间和时区与Internet时间同步
- 自动调整linux系统时间和时区与Internet时间同步
- 自动调整linux系统时间和时区与Internet时间同步
- 自动调整linux系统时间和时区与Internet时间同步
- 自动调整linux系统时间和时区与Internet时间同步
- 调整linux系统时间和时区 与Internet时间同步
- 调整linux系统时间和时区与Internet时间同步
- Linux系统的时区和时间调整
- 自动调整linux系统时间和时区与Internet时间同步 2011-11-08 09:07:04
- Linux系统的时区和时间调整发布时间
- Linux 调整时区和时间
- linux调整系统时间和时区的方法
- linux调整系统时间和时区的方法
- Couchbase 与 Memcache&…
- redis php sort 函…
- redis持久化RDB和AOF
- openssh and X11 forwarding
- php利用syslog函数分布式将log集中…
- 自动调整linux系统时间和时区与Int…
- HTML文本格式化实例
- 安装rsyslog
- CentOS 6.5下利用Rsyslog+Log…
- 用Syslog 记录UNIX和Windows…
- PHP函数补完:session_name()
- SVN UUID 变更导致提交更新错误
- media="screen"啥意思?
- MySQL命令行格式化输出