How to set the time on a Linux PC

Non-Datatex Product Support.
General support issues on PCs and Servers that is related to Datatex products.

Moderators: Leon van Heerden, Luanda_Junzi

How to set the time on a Linux PC

Postby Leon van Heerden » Mon May 28, 2012 1:08 pm

The Linux Operating System uses the time zone configured to calculate the correct time. So if you have a server in South Africa with the timezone configured as "+2" then it will use the hardware time and add 2 hours.

To set the Operating System time you use the "date" command:

Code: Select all
date 05281304

The format is MMDDHHmm

If you also need to set the year you can add the year after all the other values:
Code: Select all
date 052813042016

The format is MMDDHHmmYYYY


The hardware clock then also needs to be updated to ensure that the system will have the correct time when it is restarted again.

Use this command:

Code: Select all
hwclock --systohc


This uses the system time to set the hardware clock.
----
Leon van Heerden
http://www.datatex.co.za
Leon van Heerden
 
Posts: 332
Joined: Fri Oct 29, 2010 11:21 am
Location: Cape Town

Re: How to set the time on a Linux PC

Postby Luanda_Junzi » Fri Jun 24, 2016 8:46 am

First check both times for System and also Hardware
System time
Code: Select all
Date

Results
Code: Select all
Fri Jun 24 10:06:54 SAST 2016

Hardware Time
Code: Select all
hwclock

Results
Code: Select all
Fri 24 Jun 2016 08:07:19 SAST  -0.528705 seconds

The Hardware clock is correct.
The fore you can just Syc the time, with hwclock -s "-s is the function Set the System Time from the Hardware Clock"
Code: Select all
hwclock -s

Alternative way to setime
Code: Select all
sudo dpkg-reconfigure tzdata

It will give you the prompts you just have to select the right one's
Geographic area: Africa
Time zone: Johannesburg
Luanda_Junzi
 
Posts: 142
Joined: Wed Feb 25, 2015 2:30 pm


Return to General Support

Who is online

Users browsing this forum: No registered users and 1 guest

cron