date命令

 

 

输出时间:

[root@CentOS7 ~]# date
Sun Jan 8 23:17:03 CST 2017

 

格式化输出:
[root@CentOS7 ~]# date +%Y-%m-%d-%H:%M:%S
2017-01-08-23:17:07

 

设置时间:

[root@CentOS7 ~]# date -s "2017/1/8 23:17:00"

 

打印当前时间戳:

[root@CentOS7 ~]# date +%s
1483888808

 

具体时间--->时间戳:

[root@CentOS7 ~]# date -d '2017/1/8 23:00:00' +%s
1483887600

 

时间戳---> 具体时间:

[root@CentOS7 ~]# date -d @1483888808 +%Y-%m-%d-%H:%M:%S
2017-01-08-23:20:08
[root@CentOS7 ~]# date -d @1483888808
Sun Jan 8 23:20:08 CST 2017

 

把系统时间写入cmos

[root@CentOS7 ~]# clock -w

 

posted @ 2017-01-08 23:23  xuanhui  阅读(131)  评论(0编辑  收藏  举报