1、查看时间
[root@mysql_cluster_1 home]# date
2021年 12月 03日 星期五 23:42:52 CST
##格式化查看
[root@mysql_cluster_1 home]# date "+now time is : %Y-%m-%d %H:%M:%S"
now time is : 2021-12-03 23:47:28
###以“+”开头后接格式信息,%Y -> (完成年份0000-9999),%m -> 月份(月份01-12),%d -> 日(01-31),%H -> 小时(00-23),
###%M -> 分钟(00-59),%S -> 秒(00-59)

2、设置时间
###设置时间只能root用户有权限
[root@mysql_cluster_1 home]# date -s "2021-12-04 00:00:40"
2021年 12月 04日 星期六 00:00:40 CST
[root@mysql_cluster_1 home]# date "+now time is : %Y-%m-%d %H:%M:%S"
now time is : 2021-12-04 00:00:41

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐