Linux 时间同步配置
一. 使用 Network Time Protocol (NTP) 服务器
1.1 服务器可链接外网时
# crontab -e
加入一行:
*/1 * * * * ntpdate 210.72.145.44
210.72.145.44 为中国国家授时中心服务器地址,这样该机每隔1分重就可以与国家授时中心进行同步了。
注意: 在使用ntpdate 命令时, ntpd 服务必须是关闭的, 否则会报the NTP socket is in use, exiting 错误。
关闭 ntpd 服务命令如下:
[root@node2 init.d]# /etc/init.d/ntpd stop
Shutting down ntpd: [ OK ]
1.2. 架设本地时间服务器
需要修改 /etc/ntp.conf文件里的几个配置就可以了,比如本地时间服务器IP 为 10.85.10.119, 配置如下:
server 210.72.145.44 prefer (中国国家授时中心服务器地址 prefer表示优先 注意把默认的server更改成这样)
server 127.127.1.0 (本地时间)
restrict 10.85.10.0 mask 255.255.255.0 nomodify (允许10..85.10.* 的IP 使用该时间服务器)
restrict 0.0.0.0 mask 0.0.0.0 nomodify notrap noquery notrust (屏蔽其他IP过来更新时间)
其他的保持默认不动。
使NTP服务可以在系统引导的时候自动启动,执行:
# chkconfig ntpd on
启动/关闭/重启NTP的命令:
# /etc/init.d/ntpd start
# /etc/init.d/ntpd stop &nbs
相关文档:
方法一、
bool ReadElemnt(string& szFileName)
{
TiXmlDocument myDocument(szFileName);
bool loadOkay = myDocument.LoadFile();
if(loadOkay == false)
return false;
TiXmlElement *rootElement = myDocument.RootElement();
if(rootEle ......
[转]Linux 2.6 内核Epoll用法举例说明
epoll用到的所有函数都是在头文件sys/epoll.h中声明的,下面简要说明所用到的数据结构和函数:
所用到的数据结构:
typedef union epoll_data {
void *ptr;
int fd;
__uint32_t u32;
__uint64_t u64;
......
bool RemoveNode(string& szFileName)
{
TiXmlDocument myDocument(szFileName);
bool loadOkay = myDocument.LoadFile();
if(loadOkay == false)
return false;
//获得根元素
TiXmlElement *rootElemen ......
bool InstertNode(string& szFileName)
{
TiXmlDocument myDocument(szFileName);
bool loadOkay = myDocument.LoadFile();
if(loadOkay == false)
return false;
//获得根元素
TiXmlElement *r ......
1.shell 是系统的用户界面,提供了用户与内核进行交互操作的一种接口(命令解释器)。它接收用户输入的命令并把它送入内核去执行。起
着协调用户与系统的一致性和在用户与系统之间进行交互的作用。
Shell在Linux系统上具有极其重要的地位
Shell的版本,Linux有很多Shell
echo $SHELL 查询本系统的Shell
m ......