Wednesday, 31 May 2017

How to use Set System Date and Time in linux

To change the system date use:

# date {mmddhhmiyyyy.ss}
o
o
o
o
o
o
mm – Month
dd – Date
hh – 24 hour format
mi – Minutes
yyyy – Year
ss – seconds
For example, to set system date to Jan 31st 2008, 10:19 p.m, 53 seconds

# date 013122192009.53

You can also change system date using set argument as shown below.

# date 013122192009.53
# date +%Y%m%d -s "20090131"
# date -s "01/31/2009 22:19:53"
# date -s "31 JAN 2009 22:19:53"
# date set="31 JAN 2009 22:19:53"
To set the time only:
# date +%T -s "22:19:53"

# date +%T%p -s "10:19:53PM"

No comments:

Post a Comment

What is PS2 - Continuation Interactive Prompt in Linux

A very long command can be broken down to multiple lines by giving \ at the end of the line. The default interactive prompt for a multi-lin...