Portal Home > Knowledgebase > Articles Database > LINUX: how to change date relatively


LINUX: how to change date relatively




Posted by Mister Bark, 03-21-2012, 08:53 AM
Hi! I'd like to change the linux time of the local machine, just like we can do with the command "date -s". But I need to make it RELATIVE. i.g. something like "date -s +3" to add 3 seconds to the current date... Somebody knows a simple way to do this without crazy scripts ? THANKS!

Posted by rcs, 03-21-2012, 09:02 AM
usr/bin/rdate -s tick.greyware.com will set your date correctly.

Posted by Mister Bark, 03-21-2012, 06:54 PM
sorry rcs, I don't see any point with my question...

Posted by rcs, 03-21-2012, 07:12 PM
you want: date -s '+3 seconds'

Posted by Mister Bark, 03-21-2012, 07:13 PM
yes, but what's the point with an ntp server?

Posted by Coolraul, 03-21-2012, 07:29 PM
He doesn't want it correct. He wants it wrong for some reason.

Posted by Mister Bark, 03-21-2012, 07:41 PM
thanks Coolraul Apparently we can use date -s @1234567890 where 1234567890 is a linux time since epoch. So if there is no direct solution I could make a simple perl line with something like : system("date -s \@".(time+3) );

Posted by rcs, 03-22-2012, 06:21 AM
I'm sorry, I wasn't clear. You can actualy use: date -s '+3 seconds'

Posted by Mister Bark, 03-22-2012, 09:31 AM
OMG haha ok thanks, it works! I didn't expect a such thing to work



Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read
Hostgator or Kualo (Views: 550)
Hostdime or Crocweb? (Views: 623)