Timekeeping in Linux question ...


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Timekeeping in Linux question ...
# 1  
Old 04-10-2011
Timekeeping in Linux question ...

Hi again! I'm still learning with unixacademy dvds and I have a question related to a timekeeping. Again I'm new to Linux and UNIX and most of my computing experince is Windows. I researched this on google but couldn't find a clear answer. I've been tweeking time zones in my last excersize...

How time keeping in Linux works? Does clock in BIOS have an effect on time in system or it is completely ignored? When I use "date" command, can/should it also adjust the hardware clock? Can someone clarifyit please? I've been asking few guys around, but no one really knows...so it can be of help to many!
# 2  
Old 04-11-2011
Yes, the BIOS clock (hardware clock) is used, otherwise you wouldn't have any time at all. The date command can set the hardware clock, but you need to tell it explicitly to set the time, and what time to set (see the -s switch in man date). Usually it's recommended not to rely on the BIOS clock alone, but to use high precision time servers (usually through NTP).
This User Gave Thanks to pludi For This Post:
# 3  
Old 04-11-2011
Further to pludi who has already answered the question.

The Real Time Clock in a computer can be implemented in many ways. This link and the links off the link are good background reading.
Real-time clock - Wikipedia, the free encyclopedia

In my experience the most serious clock faults have been caused by a flat CMOS battery! Starting a unix, Linux or Windows system with the clock wrong can have unexpected consequences (e.g. software licences expiry). All these systems rely on the hardware clock.
This User Gave Thanks to methyl For This Post:
# 4  
Old 04-11-2011
Ok, again, please correct me if I'm wrong. So I set up "linux time" with "date" command and I do not use this "-s" option. Now I have two times, one is in BIOS hardware clock, another is a system time. Now, if I turn off my Linux machine for let say, prolonged perioud of time... and then I boot it... What time it will boot with? (assuming I don't use NTP) Will it be my formally incorrect BIOS time? Or there's some mechanism that can tell to a kernel how much time passed since last downtime, and it will boot with a correct time? Or it is different per /system/bios/kernel implementation?
# 5  
Old 04-11-2011
The straight answer to your question is "whatever time is held in the RTC chip". There is nowhere else that the Operating System can obtain the time.


Assuming your CMOS battery is good.
Your computer should keep the Real Time Clock running with the power off. It will also for example remember details about your disc drives.

The time will be as correct as the quality of your Real Time Clock allows.

If you have a hardware repair affecting the Real Time Clock it is imperative that the clock is set correctly BEFORE unix/linux/Windows boots. This is a CMOS function NOT a unix/Linux/Windows function.

A system with NTP will try to find a good time source and correct the Real Time Clock after boot. By this time it is much too late if the CMOS clock was wrong.




Btw. I prefer "date -a" over "date -s" but the most important task during system boot is to get the clock right.

Edit: To 100% clarify the answer. A "date" command without the "-s" or "-a" option is just an enquiry and will not change the CMOS date. Where you referred to BIOS in earlier posts, read CMOS.

Last edited by methyl; 04-11-2011 at 06:56 PM.. Reason: miscellaneous corrections and enhancements.
This User Gave Thanks to methyl For This Post:
# 6  
Old 04-12-2011
Firts, thanks to everybody who addressed the issue!
Here is one more scenario, I'm trying to understand, so if Linux machine relies on NTP and NTP is becoming unavailable, and BIOS time is differnt from NTP time, will it switch to BIOS time?
# 7  
Old 04-12-2011
There's only one system time, it doesn't use different "time sources". NTP is just used to adjust it once in a while.

The BIOS clock and the system clock aren't the same thing though. The system clock is a value kept in RAM and updated as the system goes, quite independent of the BIOS one. Ideally the system time should sync with the BIOS on power-on, and set the BIOS clock on power-off.

So the system time, once set by NTP, should stay valid without NTP, though subject to clock drift etc.

Last edited by Corona688; 04-12-2011 at 03:48 PM..
This User Gave Thanks to Corona688 For This Post:
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Linux question on directories..

Hi, First server every thing is working but keeps crashing so to be on the safe side created second server and moved all the files. But I notice there is a " dot " at the end. See below. Not sure what that means. Also getting 403 on Apache. Please see below. Thanks you so much. ls -l... (4 Replies)
Discussion started by: samnyc
4 Replies

2. UNIX for Dummies Questions & Answers

New to Linux scripting question

hello i am new to scripting and Linux in general. i am going to school for sys admin and i will need at least some knowledge on scripting. i have been so far ok with learning basic scripting now i am stuck. with a assignment that i was given it was create a script that will tell you if a number... (2 Replies)
Discussion started by: dragonwrench
2 Replies

3. Linux

Question on Linux Binary

Hi All, On linux system copied a /bin/kill to /bin/killlatest, when i tried to kill a command using /bin/killlatest it is failing with below errors /bin/killlatest 12345 ERROR: no "killlatest" support. Please help on this.. My ideas is to write a wrapper over killl command to find out who... (5 Replies)
Discussion started by: sridhar8183
5 Replies

4. UNIX for Advanced & Expert Users

Linux fdisk question (Oracle Enterprise Linux)

OS: Oracle Enterprise Linux 6.2 Hypervisor: VMWare workstation 9 I created a VM and attached a 7gb virtual disk to it. Using fdisk , I partioned the disk like below. The filesystems mounted on this is working fine. But I am seeing the message Partition n does not end on cylinder boundary.... (2 Replies)
Discussion started by: kraljic
2 Replies

5. Shell Programming and Scripting

New to Linux, have some simple question

Hi All, Here is the problem: I have done a c++ code in Visual Studio 2010, it's a simple project that only have one main function which takes 2 parameters: an integer and a file that stores data. Now, I am asked to write a shell script in linux to execute my main function. I asked my professor... (1 Reply)
Discussion started by: EasonRU
1 Replies

6. UNIX for Dummies Questions & Answers

linux installation question?

Hi I accidentally installed another operating system after I had installed Linux and now I can no longer access your Linux system.any solution? Thanks (1 Reply)
Discussion started by: adam25bc
1 Replies

7. Linux

(ASK) Question about linux network...

hi all, im linux nubie n want to ask, 1. how to access the windows pc? if from windows to windows, we can use : start-run-\\192.168.1.1\e$ now, how about from linux (fedora) n want to access to windows drive? if I use ssh from linux to windows, ssh 192.168.6.171 ssh: connect... (6 Replies)
Discussion started by: busoh.sensen
6 Replies

8. UNIX for Dummies Questions & Answers

Linux LVM Question

I've three partitions on /dev/sda: sda1, sda2 sda3. There is FREE space between sda2 and sda3 and sda3 ends on the last sector. sda2 and sda3 have the same number of sectors allocated and so are the exact same size. /dev/sda2 is already part of the VG VolGroup. However, what puzzles me is that... (0 Replies)
Discussion started by: Devyn
0 Replies

9. UNIX for Dummies Questions & Answers

Timekeeping problem

Hello everyone I am currently exploring the different time keeping commands in linux. and I having a lot of trouble figuring out the advantages and disadvantages of using daytime command rdate and hwclock and such commands. Can someone link me to good articles or just give me the answer (5 Replies)
Discussion started by: maniac173
5 Replies

10. UNIX for Dummies Questions & Answers

linux newbie question...

I'm running Vector Linux on this computer, and everythign works fine, except for the NIC. I run netconfig, and then when I reboot it says: DC21140 at 0x9400(PCI BUS 0, device 11) h/w address 00:00:C0:2E:13:dC, and reqquires IRQ 9(provided by PCI BIOS) Setting up net subsytems. ... (5 Replies)
Discussion started by: Corey
5 Replies
Login or Register to Ask a Question