Click to See Complete Forum and Search --> : Setting date & time


Dirk
01-13-2001, 11:31 AM
What is the exact format for time/date setting with the date command? Thanks

cme
01-13-2001, 11:40 AM
Not sure of the correct format, but it is with the date function. man date is faily intuitive and you can probably figure out the format from there. Something like date thedate thetime

Post back if you have any problems...

Dirk
01-13-2001, 11:46 AM
Sorry, but I found the man page to be confusing.

cme
01-13-2001, 11:59 AM
date -s HH:MM:SS to set the time.
date -s MM/DD/YYYY to set the date.

There is a way to set both at the same time, but try that. Good Luck!

posterboy
01-13-2001, 12:49 PM
This one is pretty good, too
date MMDDHHMMYYYY
it, however, does you little good unless followed by this one
hwclock --systohc
This one takes what you just set with "date" and drops into the hardware clock. Without this, the time will be wrong every time you boot, because the boot process forces the hardware time into the software. The "Final Answer" to this is NTP. It's tiny, runs with no attention, and puts your clock (both hardware and software) on atomic standards. 'Sides, it's fun to play with. www.raymondjones.net/ntpguide.html (http://www.raymondjones.net/ntpguide.html)
Ray

------------------
ray@raymondjones.net
HTTP://www.raymondjones.net

cme
01-13-2001, 12:53 PM
Good point about reboot.

Couldn't you enter BIOS setup and change it there?

Craig McPherson
01-13-2001, 04:44 PM
Originally posted by cme:
Couldn't you enter BIOS setup and change it there?

Reboot a Linux machine?

Why?

Also, remember that if you want to be an old-skool UNIX guru, you have to have your hardware clock set to GMT rather than your local timezone, and configure your operating system to adjust for your local timezone. The only reason not to do this would be, as one of the man pages so eloquently puts it, "you have another inferior operating system installed on the machine that can't handle a hardware clock being set to GMT". I do it anyway: I very rarely boot into Windows, but when I do I can tolerate having my clock five hours fast, it just serves to remind me to get back to a real OS as fast as possible.

NTP or NTPDate really is a good idea. NTPDate is a simple client program that you can run on a cron script that connects to a time server and sets your clock. NTP is a full-fledged daemon that runs all the time and contacts timeservers at regular intervals to always keep you perfectly in sync. The problem with NTP is that you have to pick time servers that'll allow you to connect to them -- many won't let you unless the admin of the server specifically allows it, and many of the "open" servers request you to drop the admin an e-mail to let him/her that you'll be syncing with his/her timeserver. Setting up the NTP server on your system to sync with other NTP servers without at least dropping their admins a quick e-mail is considered rude, unless the servers are specifically listed as open access, no e-mail.

Check ntp.org for more info, and a server list with usage guidelines.

------------------
http://users.ipa.net/~cmcpher/paminv.gif DEBIAN (http://www.debian.org/) http://users.ipa.net/~cmcpher/paminv.gif
It turns girls into statues!

[This message has been edited by Craig McPherson (edited 13 January 2001).]

Craig McPherson
01-13-2001, 04:48 PM
Here's another cool trick. If your Linux box is the server for a bunch of Windows machines, and you run SAMBA and have those Windows boxes do domain logins, set up NTP on your Linux box so that it's always in sync. Set up Samba so that it acts as an SMB Timeserver (I think this is the default behavior, so this might already be on). Then, in the login scripts, use the "net time" command so that whenever anyone logs in to any of the Windows machines, their time is synched with the Linux server. That way, you have an entire network getting its time synched correctly, with only ONE of them having to go out to a timeserver on the Internet.

If you have other Unix machines on the network, set them up so that they use ntpdate once a day or so to sync with your Linux box.

Dirk
01-14-2001, 12:48 PM
Thanks to all. I'm trying to setup xntp as I write. Wish me good fortune. Dirk