geekvenue.net

Welcome to Chucktips Hardware HELP WITH DEAD OS Installing FreeBSD Miscellaneous
 faq
 search
 add article
 cool-stuff
 how-to
 main
 tips


HOWTO: Set the Date and Time
Miscellaneous Posted by Jason on Wednesday March 28, @10:21PM
from the Time-Warp dept.
If you would like to check what time your system is set to, or set your date and time- try the date command.

[Check the Date and Time]

To check the date and time on your system, login is any user and issue the date command like so:

$ date

Wed Mar 28 20:55:47 AKST 2001

Notice the time is shown as a 24 hour clock- 20:55 is 8:55PM, in the USA this is known as military time. Also notice the timezone info, in my case AKST (Alaska Standard Time -9 GMT).


[Setting the Date and Time]

There are a couple of ways to set the date and time. You can set it manually with the date command, or by using an internet time server with the ntpdate command.

[Set the Time Manually]
To set the date and time as it is displayed in the above example, login as root and issue the date command with the following parameters:

Login: root
Password: ********

# date 010328205547


Here is how to break it down number by number:

  01 - The Year: 2001
  03 - The Month: March
  28 - The Day : 28th
  20 - The Hour: 8pm
  55 - The Minutes: 55
  47 - The seconds: 47

[Set the Time Using a Time Server]
If your FreeBSD box has access to the internet, you can use an internet time server to set your date and time. Login as root and issue the ntpdate command:

Login: root
Password: ********

# ntpdate time.some-time-server.com

28 Mar 20:26:20 ntpdate[591]: adjust time server 192.168.1.251 offset -4.178968 sec

Notice that according to the time server at my time provider (bogus ip in my example), my time was off by about 4 seconds.

If you would like more information on these commands, I recommend the man pages.

  man date
  man ntpdate


<  |  >

 

Related Links
  • Articles on Miscellaneous
  • Also by Jason
  • Contact author

    Lilliput Mini USB Computer Monitor

    If you have ever wanted to learn about Cisco Routers, check out my new book "Cisco Routers for the Small Business" - it's Cisco CLI for the Regular Guy!

  • Sponsors

    The Fine Print: The following comments are owned by whoever posted them.
    ( Add a Reply )

    Re: HOWTO: Set the Date and Time
    by Felix on Tuesday September 03, @05:14AM
    lowrider# date Tue Sep 3 15:13:28 CEST 2002 lowrider# date -n 1407; date Tue Sep 3 14:07:00 CEST 2002 Tue Sep 3 15:13:31 CEST 2002 What am I doing wrong? /var/log/messages tells: Sep 3 15:17:11 lowrider /kernel: Time adjustment clamped to -1 second Sep 3 15:17:11 lowrider date: date set by felix
    [ Add a Reply to this ]
    • Time adjustment clamped
      by Alister Lee on Saturday May 24, @01:32AM
      This relates to the kernel security setting you are running init at (changed under security settings with sysinstall). See man init for more information.
      [ Reply to this ]
    Re: HOWTO: Set the Date and Time
    by mooky mooksgill on Thursday January 09, @03:38PM
    in your date example, i think there needs to be a dot separating seconds - as in #date 0103282055.47 thanks, mooky
    [ Add a Reply to this ]
    Re: HOWTO: Set the Date and Time
    by RON D`ADDIO on Sunday March 09, @08:40AM
    Hi! I`m writing because I just got a fax machine and to set time I need to set it 24 hour format. But the problem is I`m not familiar with this type of time. Can you help me with an easier way of understanding how to do this. I`m completely new to this. Please sent me informaion as soon as possible. Thanks , Ron
    [ Add a Reply to this ]
    Re: HOWTO: Set the Date and Time
    by Shawn on Wednesday March 19, @05:46PM
    this is how it works on my Redhat 8.0 box: #date 0319203603.50 Wed Mar 19 20:36:33 EST 2003 from left to right: 03 - Month 19 - date 20 - hour (8pm) 36 - minute 03 - year (2003) .50 - second (note the dot in front of it)
    [ Add a Reply to this ]
    Re: HOWTO: Set the Date and Time
    by mhike on Thursday July 24, @09:15PM
    install rdate from ports:

    cd /usr/ports/sysutils/rdate

    make install & make clean

    paste the following to /etc/crontab

    sync your time every 2 am everyday :

    0 2 * * * root /usr/local/sbin/rdate nist1.datum.com
    [ Add a Reply to this ]
    The Fine Print: The following comments are owned by whoever posted them.
    ( Article Reply )

    "You never know how many friends you have until you own a Condo on the beach." -- Jason's Postulate

    Powered by Zope  Powered by Apache  Squishdot Powered
    All trademarks and copyrights on this page are owned by their respective companies. Comments are owned by the Poster. The Rest ©2001 Jason Neumann.
    [ main | post article | search ]