CentOS 7 学习笔记(一)时间管理
1 获取当前时间
[root@limt01 ~]# date
2015年 05月 22日 星期五 01:30:50 CST
2 获取当前日期
[root@limt01 ~]# date "+%Y%m%d"
20150522
3 获取三天之前日期
[root@limt01 ~]# date -d "-3 days" "+%Y%m%d"
20150519
4 获取三天之后的日期
[root@limt01 ~]# date -d "+3 days" "+%Y%m%d"
20150525
5 获得月末日期
[root@limt01 ~]# cal|xargs|awk '{ print $NF }'|sed 's/ //g'
31
6 查看时区
[root@limt01 ~]# date -R
Fri, 22 May 2015 01:45:26 +0800 (+0800 表示东八区)
7 设置时间
[root@limt01 ~]# date 0522082515
2015年 05月 22日 星期五 08:25:00 CST
或者
[root@limt01 ~]# date -s "2015-05-22 08:25:22"
2015年 05月 22日 星期五 08:25:22 CST [root@limt01 ~]# hwclock -r //读入BIOS时间
2015年05月22日 星期五 01时50分54秒 -0.726681 秒
[root@limt01 ~]# hwclock -w //向BIOS写入时间
[root@limt01 ~]# hwclock -r
2015年05月22日 星期五 08时26分08秒 -0.582655 秒
8 检测时区配置
[root@limt01 sysconfig]# timedatectl
Local time: 五 2015-05-22 08:30:02 CST
Universal time: 五 2015-05-22 00:30:02 UTC
RTC time: 五 2015-05-22 00:29:44
Timezone: Asia/Shanghai (CST, +0800)
NTP enabled: yes
NTP synchronized: no
RTC in local TZ: no
DST active: n/a
9 列出所有时区
[root@limt01 sysconfig]# timedatectl list-timezones
Africa/Abidjan
Africa/Accra
Africa/Addis_Ababa
Africa/Algiers
Africa/Asmara
Africa/Bamako
Africa/Bangui
Africa/Banjul
Africa/Bissau
Africa/Blantyre
Africa/Brazzaville
10 设置时区
[root@limt01 sysconfig]# timedatectl set-timezone Asia/Shanghai (设置系统时区为上海)
[root@limt01 sysconfig]# timedatectl set-local-rtc 0 # 将硬件时钟调整为与本地时钟一致, 0 为设置为 UTC 时间
11 NTP服务(端口123)
/usr/sbin/ntpdate xxx.xxx.xxx.xxx 手工与指导ntp服务器同步时间
NTP服务进程:
[root@limt01 ntp]# ps -ef|grep ntp|grep -v grep
ntp 4304 1 0 08:32 ? 00:00:00 /usr/sbin/ntpd -u ntp:ntp -g
启动NTP服务:
[root@limt01 ntp]# systemctl start ntpd.service
[root@limt01 ntp]# systemctl status ntpd.service
ntpd.service - Network Time Service
Loaded: loaded (/usr/lib/systemd/system/ntpd.service; enabled)
Active: active (running) since 五 2015-05-22 08:44:05 CST; 3s ago
Process: 4398 ExecStart=/usr/sbin/ntpd -u ntp:ntp $OPTIONS (code=exited, status=0/SUCCESS)
Main PID: 4399 (ntpd)
CGroup: /system.slice/ntpd.service
└─4399 /usr/sbin/ntpd -u ntp:ntp -g 5月 22 08:44:05 limt01 ntpd[4399]: Listen and drop on 1 v6wildcard :: UDP 123
5月 22 08:44:05 limt01 ntpd[4399]: Listen normally on 2 lo 127.0.0.1 UDP 123
5月 22 08:44:05 limt01 ntpd[4399]: Listen normally on 3 eno16777736 192.168.1.104 UDP 123
5月 22 08:44:05 limt01 ntpd[4399]: Listen normally on 4 lo ::1 UDP 123
5月 22 08:44:05 limt01 ntpd[4399]: Listen normally on 5 eno16777736 fe80::20c:29ff:fe38:2d00 UDP 123
5月 22 08:44:05 limt01 ntpd[4399]: Listening on routing socket on fd #22 for interface updates
5月 22 08:44:05 limt01 ntpd[4399]: 0.0.0.0 c016 06 restart
5月 22 08:44:05 limt01 ntpd[4399]: 0.0.0.0 c012 02 freq_set kernel 0.000 PPM
5月 22 08:44:05 limt01 ntpd[4399]: 0.0.0.0 c011 01 freq_not_set
5月 22 08:44:06 limt01 ntpd[4399]: 0.0.0.0 c614 04 freq_mode
ntpdate 与 ntpd 不能同时使用
查看NTP同步状态:
[root@limt01 ntp]# /usr/sbin/ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
+news.neu.edu.cn 236.43.203.76 2 u 67 64 3 16.655 7.426 1.443
*dns2.synet.edu. 202.118.1.46 2 u 2 64 3 15.917 8.520 1.687
配置文件/etc/ntp.conf
[root@limt01 ntp]# less /etc/ntp.conf
# For more information about this file, see the man pages
# ntp.conf(5), ntp_acc(5), ntp_auth(5), ntp_clock(5), ntp_misc(5), ntp_mon(5). driftfile /var/lib/ntp/drift # Permit time synchronization with our time source, but do not
# permit the source to query or modify the service on this system.
restrict default nomodify notrap nopeer noquery # Permit all access over the loopback interface. This could
# be tightened as well, but to do so would effect some of
# the administrative functions.
restrict 127.0.0.1
restrict ::1 # Hosts on local network are less restricted.
#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap # Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
server 0.centos.pool.ntp.org iburst
server 1.centos.pool.ntp.org iburst
server 2.centos.pool.ntp.org iburst
server 3.centos.pool.ntp.org iburst #broadcast 192.168.1.255 autokey # broadcast server
#broadcastclient # broadcast client
#broadcast 224.0.1.1 autokey # multicast server
#multicastclient 224.0.1.1 # multicast client
#manycastserver 239.255.254.254 # manycast server
#manycastclient 239.255.254.254 autokey # manycast client # Enable public key cryptography.
#crypto includefile /etc/ntp/crypto/pw # Key file containing the keys and key identifiers used when operating
# with symmetric key cryptography.
keys /etc/ntp/keys # Specify the key identifiers which are trusted.
#trustedkey 4 8 42 # Specify the key identifier to use with the ntpdc utility.
#requestkey 8 # Specify the key identifier to use with the ntpq utility.
#controlkey 8 # Enable writing of statistics records.
#statistics clockstats cryptostats loopstats peerstats # Disable the monitoring facility to prevent amplification attacks using ntpdc
# monlist command when default restrict does not include the noquery flag. See
# CVE-2013-5211 for more details.
# Note: Monitoring will not be disabled with the limited restriction flag.
disable monitor
CentOS 7 学习笔记(一)时间管理的更多相关文章
- Linux学习笔记(六) 进程管理
1.进程基础 当输入一个命令时,shell 会同时启动一个进程,这种任务与进程分离的方式是 Linux 系统上重要的概念 每个执行的任务都称为进程,在每个进程启动时,系统都会给它指定一个唯一的 ID, ...
- 蓝牙芯片NRF51822入门学习1:时间管理
前言 之前辞职找工作的时候发现,很多公司希望招聘蓝牙技术方面的人才,所以干脆丢开LWIP静下心来学习蓝牙技术.原本以为一两星期能基本学会的,谁知道所选的蓝牙芯片nrf51822是个坑货,坑了我一个月. ...
- Linux内核学习笔记-2.进程管理
原创文章,转载请注明:Linux内核学习笔记-2.进程管理) By Lucio.Yang 部分内容来自:Linux Kernel Development(Third Edition),Robert L ...
- linux kernel学习笔记-5内存管理_转
void * kmalloc(size_t size, gfp_t gfp_mask); kmalloc()第一个参数是要分配的块的大小,第一个参数为分配标志,用于控制kmalloc()的行为. km ...
- Linux学习笔记(五) 账号管理
1.用户与组账号 用户账号:包括实际人员和逻辑性对象(例如应用程序执行特定工作的账号) 每一个用户账号包含一个唯一的用户 ID 和组 ID 标准用户是系统安装过程中自动创建的用户账号,其中除 root ...
- Qt学习笔记-Widget布局管理
Qt学习笔记4-Widget布局管理 以<C++ GUI Programming with Qt 4, Second Edition>为参考 实例:查找对话框 包含三个文件,f ...
- XV6学习笔记(2) :内存管理
XV6学习笔记(2) :内存管理 在学习笔记1中,完成了对于pc启动和加载的过程.目前已经可以开始在c语言代码中运行了,而当前已经开启了分页模式,不过是两个4mb的大的内存页,而没有开启小的内存页.接 ...
- pygame学习笔记(3)——时间、事件、文字
转载请注明:@小五义 http://www.cnblogs.com/xiaowuyi 1.运动速率 上节中,实现了一辆汽车在马路上由下到上行驶,并使用了pygame.time.delay(200 ...
- 操作系统学习笔记4 | CPU管理 && 多进程图像
操作系统的核心功能就是管理计算机硬件,而CPU就是计算机中最核心的硬件.而通过学习笔记3的简史回顾,操作系统通过多进程图像实现对CPU的管理.所以多进程图像是操作系统的核心图像. 参考资料: 课程:哈 ...
随机推荐
- Ubuntu14.04源
Ubuntu14.04源: 来源: http://wiki.ubuntu.org.cn/Qref/Source (包含15.04.14.10.14.04.12.04.10.04的源) Ub ...
- Appium for iOS setup
windows下appium设置 之前研究了一段时间的appium for native app 相应的总结如下: ...
- jeecms3.0.4版本 详解请求如何找到首页(转)
第一步:发送http://localhost:8080/emisstrade/ 请求 第二步:首先进入配置文件web.xml, <context-param> <param-name ...
- DataTable导出到Excel
简单的导出到Excel中: 代码如下: using System; using System.Collections.Generic; using System.Data; using System. ...
- Visual Studio Emulator for Android 的安装与使用 感觉最干净好看的模拟器.
Step1 win8+ 6G+ 添加删除程序\ hyper 创建虚拟机 安装visual studio android 模拟器, 自带三个模拟器 使用管理员打开模拟器 参考文献 Visual Stu ...
- 1.1Axure简介
1.部件:点击部件右上角的?,可以看到相关注释,注释底部有网站链接,可查看部件的详细介绍.
- ArrayList、Vector、LinkedList源码
List接口的一些列实现中,最常用最重要的就是这三个:ArrayList.Vector.LinkedList.这里我就基于JDK1.7来看一下源码. public class ArrayList< ...
- 大数据系列-CDH环境中SOLR入数据
1 创建集合 SSH远程连接到安装了SOLR的CDH节点. 运行solrctl instancedir --generate /solr/test/GX_SH_TL_TGRYXX_2 ...
- 网站开启https后加密协议始终是TLS1.0如何配置成TLS1.2?
p { margin-bottom: 0.1in; line-height: 120% } 网站开启https后加密协议始终是TLS1.0如何配置成TLS1.2? 要在服务器上开启 TLSv1.,通常 ...
- PHP socket上传文件图片
最近了解了下下socket方面的东西,想做一个socket上传文件的例子. 在网上搜了搜代码执行后,图片数据传输了一半,图片的下半部分是灰色的.然后就自己仿着搜来的代码和php.net 中socket ...