在Linux中将x秒添加到当前日期 [英] Add x seconds to the current date in Linux

查看:171
本文介绍了在Linux中将x秒添加到当前日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我这里有两台Linux(CentOS 6.0)计算机,我需要在当前日期时间增加(或删除)5秒。最后,我的两台机器之间的间隔为5秒(一台机器的时间正确,另一台机器的时间相差5秒或更短)。

I have two Linux (CentOS 6.0) machines over here and I need to add (or remove) 5 seconds to the current date time. In the end, both my machines would have a gap of 5 seconds (one with the right time and the other one with 5 seconds more or less).

我知道可以使用以下命令更改日期:

I know I can change the date with this command:

date -s "DD MMM YYYY HH:MM:SS"

但是我需要非常精确,这对我来说很难在正确的时间运行命令。

but I need to be precise and it will be hard for me to run the command at the right time.

所以我想知道是否有一种方法可以将当前时间增加5秒,有点像您选择格林威治时区(+5小时)

So I'd like to know if there is a way in general to add 5 seconds to the current time, a bit like when you choose your time zone compared to Greenwich (+5 hours in my case).

推荐答案

您可以使用 date在一条命令中将当前时间增加5秒-s 5秒

这篇关于在Linux中将x秒添加到当前日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆