Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have an embedded system with Busybox and uClibc. The system time is set automatically from RTC at boot time. When running the date command I get the following output:

Thu Jan  1 01:10:41 GMT 1970

When i run the hwclock command I get the following output:

Thu Jan  1 00:00:00 1970  0.000000 seconds

I have now configured my timezone in /etc/TZ, but I do not know what time I should set the RTC clock to, for everything to display correct when running the date command?

share|improve this question
1  
Install NTP, and let it set get the proper time from the network/internet? –  Zoredache May 7 '12 at 23:14

3 Answers 3

To change the date, use the date command:

date MMDDhhmm[[CC]YY][.ss]]
date 0507192912 # Mon May  7 19:29:00 EDT 2012

To synchronize clocks, use hwclock.

Set hardware clock from system clock:

hwclock --systohc

Set system clock from hardware clock:

hwclock --hctosys
share|improve this answer

Dont set the hardware clock manually, use hwclock --systohc. This will automatically take care of any timezone settings you have in effect.

EDIT:
After re-reading your question, I think you also meant to ask how to set the system time. The system keeps its own time separate from the hardware. You can use the date command to set this manually, or ntpdate to set it from a remote source via ntp (or run ntp as a daemon to have it constantly updated).

share|improve this answer

To synchronize clocks use hwclock --systohc

But I think setting up sysclock using date isn't the best solution. The best way is to sychronize sysc clock with some of time servers using rdate or ntp.

To do this with rdate u can add simple script to /etc/cron.daily


#!/bin/bash
rdate -s time.server.domain.name.com

Setting up time manualy with date is something like neverendless story.

share|improve this answer
    
Better to use NTP as suggested by @zoredache. Setting the time at regular intervals will cause the clock to "jump" regularly causing all sorts of issues (e.g. cron jobs not running or running twice), while NTP will keep your clock in sync constantly using small adjustments that do not affect the system adversely. –  Bram May 8 '12 at 7:19
    
@Bram yes you are right. Better solution is ntp. But I just wanted to show how simple it is ... maybe example with rdate wasnt the best :D –  B14D3 May 8 '12 at 11:43

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.