Previous Page | Next Page

  1. Introduction
  2. About Linux
  3. Installation and getting started
  4. Logging in and out
  5. Basic Linux Commands
  6. Linux Files and File Permissions
  7. Linux Directory Structure
  8. Finding Files
  9. Linux Help
  10. Setting Time
  11. Devices
  12. Tips
  13. Accessing Other Filesystems
  14. Accessing Removable Media
  15. Making and Managing Filesystems
  16. Emergency Filesystems and Procedures
  17. LILO and Runlevels
  18. Init
  19. Environment, Shell Selection, and Startu
  20. Linux Kernel
  21. Package Installation and Printing
  22. Configuration, Logging and CRON
  23. Keys and Terminal Configuration
  24. Sound Configuration
  25. Managing Users
  26. Passwords
  27. Process Control
  28. Configuration and Diagnostic Tools
  29. Overall Configuration
  30. Using PAM
  31. Basic Network Setup
  32. Tools and Terms
  33. Novell and Printing
  34. Inetd Services
  35. Xinetd Services
  36. Other Network Services
  37. FTP and Telnet
  38. Samba
  39. Identd (auth)
  40. X Configuration
  41. X Use
  42. Using X Remotely
  43. X Documentation
  44. DNS
  45. DHCP and BOOTP
  46. Apache
  47. NFS
  48. PPP
  49. Mail
  50. Routing
  51. IP Masquerading
  52. Proxy Servers and ipchains
  53. UUCP
  54. News
  55. NIS
  56. Network Security
  57. Secure Shell
  58. Text Processing
  59. Shell Programming
  60. Emacs
  61. VI
  62. Recommended Reading
  63. Credits

Setting Linux Time

Programs for working with time and date are:

  • clock - This is a soft link to hwclock.
  • date(1) - Print or set the system date and time.
  • hwclock(8) - Sets the hardware clock based on values entered on the command line.
  • setclock(8) - Sets the BIOS hardware clock based on the time and setup of the system clock.
  • timeconfig(8) - A program used to configure the system configuration file "/etc/sysconfig/clock" which includes the type of clock and timezone.

An Example:

While logged in as root do the following:

  1. Type "date".
  2. You should see some variation of"

    "Wed Nov 24, 9:29:17 EST 1999"

  3. To change the time type(as an example):

    date -s 10:10

  4. The system response will be:

    "Wed Nov 24, 10:10:02 EST 1999"

  5. Then if you want to set the hardware(BIOS) clock so the system will keep the time when it reboots type:

    clock -w

    or

    setclock

The program setclock will set your hardware clock based on your system configuration parameters including whether or not your clock is set to universal time.

The "clock -w" command assumes your hardware clock is set to local time. If it is set for universal time you will want to type "clock -wu" rather than the "clock -w" in the line above. If you use the wrong option the time will be set incorrectly and you will need to do it again.

On a Redhat system, you can use the program "linuxconf" as root and page down to the next to the last line in the menu which is "date & time". Select it and see if the box named "universal format(GMT)", next to "Store date in CMOS", is checked. If is is not, you may save your time by typing "clock -w". If it is checked use "clock -wu".

Note: There is a man page for date that you can use to learn more. Type "man date". You do not want to make any more changes to time and especially to the date than necessary, especially while the system is running, since this can trigger the "cron" daemon to perform various time related system tasks.

An alternate method to set time is. 
hwclock --set --date "2/24/2000" 		If you are using local time
hwclock --set --date "2/24/2000" -utc		If you are using universal time 

In the rc.sysinit startup script, this program is used with the options -adjust and -hctosys to adjust the hardware clock for drift, and set the system time to the hardware clock at the time of reboot.

On Redhat systems, there is a configuration program called "timeconfig" which can be used to configure the system configuration file /etc/sysconfig/clock and /etc/localtime. This program will use a graphical interface to let the user set the timezone and whether UTC time is used.