[root@V3B01-zsy yum.repos.d]# date -s "2019-09-24 17:02:30"
2019年 09月 24日 星期二 17:02:30 CST
[root@V3B01-zsy yum.repos.d]# hwclock --show
2019年09月25日 星期三 01时01分42秒 -0.689057 秒
[root@V3B01-zsy yum.repos.d]# hwclock --set --date "2019-09-24 17:03:30"
[root@V3B01-zsy yum.repos.d]#
[root@V3B01-zsy yum.repos.d]# hwclock --show
2019年09月24日 星期二 17时03分35秒 -0.750970 秒
[root@V3B01-zsy yum.repos.d]# hwclock --hctosys
[root@V3B01-zsy yum.repos.d]# clock -w
[root@V3B01-zsy yum.repos.d]#
[root@V3B01-zsy yum.repos.d]# hwclock --show
2019年09月24日 星期二 17时04分02秒 -0.813435 秒
[root@V3B01-zsy yum.repos.d]#
[root@V3B01-zsy yum.repos.d]#
[root@V3B01-zsy yum.repos.d]# timedatectl
Local time: 二 2019-09-24 17:05:16 CST
Universal time: 二 2019-09-24 09:05:16 UTC
RTC time: 二 2019-09-24 17:03:51
Time zone: Asia/Shanghai (CST, +0800)
NTP enabled: no
NTP synchronized: no
RTC in local TZ: no
DST active: n/a
[root@V3B01-zsy yum.repos.d]# timedatectl set-local-rtc 1
[root@V3B01-zsy yum.repos.d]#
[root@V3B01-zsy yum.repos.d]#
[root@V3B01-zsy yum.repos.d]# timedatectl
Local time: 二 2019-09-24 17:06:03 CST
Universal time: 二 2019-09-24 09:06:03 UTC
RTC time: 二 2019-09-24 17:06:03
Time zone: Asia/Shanghai (CST, +0800)
NTP enabled: no
NTP synchronized: no
RTC in local TZ: yes
DST active: n/a Warning: The system is configured to read the RTC time in the local time zone.
This mode can not be fully supported. It will create various problems
with time zone changes and daylight saving time adjustments. The RTC
time is never updated, it relies on external facilities to maintain it.
If at all possible, use RTC in UTC by calling
'timedatectl set-local-rtc 0'.
[root@V3B01-zsy yum.repos.d]#
[root@V3B01-zsy yum.repos.d]# timedatectl set-timezone Asia/Shanghai
[root@V3B01-zsy yum.repos.d]#
[root@V3B01-zsy yum.repos.d]# hwclock --show
2019年09月24日 星期二 17时07分11秒 -0.407534 秒
[root@V3B01-zsy yum.repos.d]#
[root@V3B01-zsy yum.repos.d]# init 6 Last login: Wed Sep 25 00:57:21 2019 from 172.16.52.201
[root@V3B01-zsy ~]#
[root@V3B01-zsy ~]#
[root@V3B01-zsy ~]# date
2019年 09月 24日 星期二 17:13:09 CST
[root@V3B01-zsy ~]#

参考以下

安装在虚拟机上的CentOS7的时间分为系统时间和硬件时间。二者都修改,重启系统(init 6 )才会永久生效。
修改步骤如下
1.查看当前系统时间 date
2.修改当前系统时间 date -s "2018-2-22 19:10:30
3.查看硬件时间 hwclock --show
4.修改硬件时间 hwclock --set --date "2018-2-22 19:10:30"
5.同步系统时间和硬件时间 hwclock --hctosys
6.保存时钟 clock -w
7.重启系统(init 6)后便发现系统时间被修改了
时区的修改
yum -y install ntp [root@localhost kevin]# systemctl enable ntpd
systemctl start ntpd ntpdate us.pool.ntp.org Linux 系统(我特指发行版, 没说内核) 下大部分软件的风格就是不会仔细去考虑向后 的兼容性, 比如你上个版本能用这种程序配置, 没准到了下一个版本, 该程序已经不见了. 比如 sysvinit 这种东西. 设置时区同样, 在 CentOS 7 中, 引入了一个叫 timedatectl 的设置设置程序. 用法很简单: # timedatectl # 查看系统时间方面的各种状态
Local time: 四 2014-12-25 10:52:10 CST
Universal time: 四 2014-12-25 02:52:10 UTC
RTC time: 四 2014-12-25 02:52:10
Timezone: Asia/Shanghai (CST, +0800)
NTP enabled: yes
NTP synchronized: yes
RTC in local TZ: no
DST active: n/a # timedatectl list-timezones # 列出所有时区 # timedatectl set-local-rtc 1 # 将硬件时钟调整为与本地时钟一致, 0 为设置为 UTC 时间 # timedatectl set-timezone Asia/Shanghai # 设置系统时区为上海 其实不考虑各个发行版的差异化, 从更底层出发的话, 修改时间时区比想象中要简单: # cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

reboot和init 6的区别

Linux中重启的两个命令:reboot和init 6之间的区别

init命令用于改变操作系统的运行级别。
Init 6是重新启动机器。
reboot也是重新启动机器。
那么这两个命令到底有什么区别呢?
对这两个操作使用man命令看到的内容如下:
"init 6" 基于一系列/etc/inittab文件,并且每个应用都会有一个相应shutdown脚本。
'init 6' 调用一系列shutdown脚本(/etc/rc0.d/K*)来使系统优雅关机;
'reboot'并不执行这些过程,reboot更是一个kernel级别的命令,不对应用使用shutdown脚本。 .
我们应该在通常情况下使用 init 6.
reboot - reboot performs a sync(1M) operation on the disks, and then a
multi- user reboot is initiated. See init(1M) for details.
init 6 Stop the operating system and reboot to the
state defined by the initdefault entry in
/etc/inittab.
在出问题的状况下或强制重启时使用reboot.

最新文章

  1. 总结下用Vue.js和webpack遇到的问题
  2. Hibernate的多表查询,分装到一个新的实体类中的一个方法
  3. 【Lucene实验1】构建索引
  4. Using Text_IO To Read Files in Oracle D2k
  5. js如何把字符串转换成json数据的方法
  6. hdu 1255 覆盖的面积
  7. nginx源代码分析--配置文件解析
  8. Windows下sass的安装
  9. php单元测试到底是什么东西呢?
  10. Android OpenGL ES 入门系列(二) --- 环境搭建
  11. C#字符串转二进制、二进制转字符串
  12. The application to execute does not exist: 'C:\Users\Administrator\.dotnet\tools\.store\dotnet-aspnet-codegenerator\2.2.0-rtm-35687\dotnet-aspnet-codegenerator\2.2.0-rtm-35687\tools\netcoreapp2.1\any\
  13. P2880 [USACO07JAN]平衡的阵容Balanced Lineup(RMQ的倍增模板)
  14. WireShark Wifi认证数据包分析(论文idea)
  15. 【java】final修饰符介绍
  16. java reflect反射调用方法invoke
  17. C#委托总结-入门篇
  18. Xpath注入学习
  19. 对HTTP和TCP的理解
  20. (转)Scala的“=>”符号简介

热门文章

  1. Java 线程和操作系统的线程有啥区别?
  2. WERTYU UVA - 10082
  3. Day17_106_IO_利用Buffered和BufferWriter完成复制
  4. C++雾中风景17:模板的非推断语境与std::type_identity
  5. Kafka2.8安装
  6. 微软加入字节码联盟,进一步开发支持Blazor 的WebAssembly技术
  7. LINQPad,我的C#/.NET学习诀窍
  8. 4- MySQL创建表以及增删改查
  9. 转载:Windows使用tail -f 监控文件
  10. hdu3336 KMP + DP 前缀数组出现的次数