• date "+%F %T"

centos7 date时间命令

%F     full date; same as %Y-%m-%d    --相当于年月日格式

%T     time; same as %H:%M:%S    --相当于时分秒格式

 

  • 将日期信息输出到文件名中
echo "abcd">>test.log-$(date "+%F-%T")

centos7 date时间命令

 

  •  -d

时间向后一天

date "+%F-%T" -d "+1day"

时间向前一天

date "+%F-%T" -d "-1day"  

  

 

  • 同步时间

需要安装ntpdate,未安装输入下面命令安装

yum -y install ntpdate

同步时间

ntpdate ntp1.aliyun.com

 

 

相关文章:

  • 2021-05-15
  • 2021-12-05
  • 2021-10-21
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-05-04
  • 2022-12-23
  • 2022-12-23
  • 2021-11-13
  • 2022-12-23
  • 2021-12-29
相关资源
相似解决方案