Time Tools
Summary:- Timing Processes
- Inquiring Time And Date
- Calendar
- Time Zones And Setting Time
- Keeping Time
- High Accuracy NTP Server
Timing Processes
Confusingly enough there's atime
$ time updatedb<br> 1.10user 0.56system 0:01.69elapsed 98%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (390major+1742minor)pagefaults 0swaps
The following values tell you something about the memory and input/output (I/O) resources used by the process (read
man time
times
This bash specific command prints "the accumulated user and system times for processes run from the shell." section index
Inquiring Time And Date
Most window managers and desktop environments offer their own graphical time and date tools and / or applets. The Mandrake Control Center also comes with an embedded time utility, draktime ('System' - 'Date & Time'). Most if not all of these tools are graphical interfaces to thedate
$ date<br> Thu Nov 1 13:04:19 CET 2001
- '-d' allows you to inquire times and dates which are not 'now':
$ date -d yesterday<br> Wed Oct 31 13:12:30 CET 2001
$ date -d 1969-04-16<br> Wed Apr 16 00:00:00 CET 1969
$ date -d pst<br> Thu Nov 1 09:00:00 CET 2001
- '-s' allows the system administrator to set the system time and date:
date -s 2001-11-01<br> date -s 21:08:0
- '-u' is a shortcut option for '-d utc' and displays the current Universal Coordinated Time (formerly known as 'Greenwich Mean Time, GMT').
$ date -d "1965-05-20" +%U<br> 20$ date -d "1965-05-20" +'Week: %U, Day Nr: %j, Day: %a'<br> Week: 20, Day Nr: 140, Day: ThuCalendar
Thecal
$ cal November 2001 Mo Tu We Th Fr Sa Su 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
- '-3' displays the calendars of the previous, current and next month side by side.
- '-y' displays the calendar for the current year.
- '{month} {year}' displays the specified month of the specified year:
$ cal 09 1958 September 1958 Mo Tu We Th Fr Sa Su 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
Time Zones And Setting Time
The world is divided into 25 time zones, with UTC (former GMT) being the 'zero' zone. Before the widespread use of the DOS and Windows 9x operating systems, computer hardware clocks were usually set to UTC and the operating system would handle the conversion to the actual time zone. DOS and its derivatives however can't do this conversion, they assume that the hardware clock time is the current time. That is, if you set your hardware clock to UTC, Unix operating systems and Windows NT and successors will display the current time whereas DOS and derivatives will display the UTC. If you dual-boot with latter operating systems, it is recommended to set the hardware clock to the current time. If not, set it to UTC. Mandrake Linux defaults to setting the clock to local time.Most time related problems on Linux like 'jumping' system times, shifting time stamps in various applications (especially in mail programs), no automatic Daylight Saving Time switching are due to the fact that the hardware clock is not set to UTC. Information on the current time zone and hardware clock setting is stored in '/etc/sysconfig/clock'. To see which time zones are available or to set a per user time zone via the TZ variable, use the
tzselect
date -s
The command line tool to set the hardware clock is
hwclock
# hwclock ––show<br> Thu 01 Nov 2001 04:05:19 PM CET -0.106658 seconds
hwclock ––set ––date="01 Nov 2001 04:00:00"- 'hctosys' sets the system time to the current hardware clock time.
- 'systohc' sets the hardware clock time to the current system time.
- 'adjust' corrects the hardware clock by the 'systematic drift' time recorded in '/etc/adjtime' (and displayed by the 'hwclock show' command).
Keeping Time
During the installation of Mandrake Linux you are given the possibility to configure an NTP (Network Time Protocol) client to keep your computer's time in sync over a network. For a single workstation and the once-in-a-while time synchronization it is a bit of an overkill. A quick and dirty solution is the ancientrdate
- use a Secondary (stratum 2) Time Server, since the Primary Time Servers are often busy,
- observe the rules of the NTP server in question,
- choose a server in your geographical vicinity,
- use the server only when you really need it (once a day should do).
rdate -p {server address}
{server address} Thu Nov 1 17:12:07 2001
rdate -s {server address}
High Accuracy NTP Server
This section describes how to configure a time server to achieve a degree of accuracy along the lines of +/- 0.00001 seconds accuracy or better. This server tracks the skew of your system clock and constantly adjusts it to match a derived signal based on the official atomic clock at the U.S. Naval Observatory. This method has a few advantages over the method of the previous section. The single largest advantage is the accuracy that it maintains. First, install the ntp package. There are actually two time servers shipped with Mandrake 8.2, ntp and xntp. For the purposes of this document, we will just use ntp.urpmi ntp
/etc/ntp.conf
# Sites commonly use the names "time", "tick", or "tock".<br> server time.domain1.com prefer<br> server tick.domain2.com<br> server tock.domain3.com<br> server 127.127.1.0 # local clock<br> fudge 127.127.1.0 stratum 10
service ntpd start<br> chkconfig ntpd on
time.yourdomain.com
time.yourdomain.com
Related Resources:
man time
info date
man cal
man hwclock
man rdate
The Clock Mini-HOWTO
/usr/share/doc/ntp-{..}
Author: Tom Berger, Todd Lyons Legal: This page is covered by the GNU Free Documentation License. Standard disclaimers of warranty apply. Copyright LSTB and Mandrakesoft.
Time Tools
Version 1.4 last modified by BjornUnden6 on 24/10/2004 at 16:16
Version 1.4 last modified by BjornUnden6 on 24/10/2004 at 16:16
Document data
- Lost account?
- Join the community, be part of the Club: it's free!
- Get the PWP Download Subscription!
Mandriva.com
Store
Club

