Set date and time from command prompt

If the Linux server time and date is wrong and you need to set it to new values from the shell prompt, you should use date command. You must login as root user to use date command. Also from command prompt you can check and set system clock (hwclock command).

Use the following syntax to set new data and time:

# date -s "16 MAR 2010 09:36:00"

Also you can use next syntax:

date set="16 MAR 2010 09:36:00"

After you set date and time, it is good idea to check your system clock with

# hwclock --show

If there is some difference you can sync system date and time with

# hwclock --systohc

Leave a Reply

Your email address will not be published. Required fields are marked *