Having the correct time, especially on your server, is important for security and data accuracy. To insure that you have the correct time on your server, you will write a simple shell script that the system will automatically run every day to set the system and hardware clocks on your server. You might want to run this script on your workstations, too. To begin, change directories: cd /usr/local/sbin Once in this directory, you will begin your shell script by invoking pico: pico w set-time This command will begin a new document called set-time that will become a small program when youre finished. In the pico editor, type the following: #!/bin/bash /usr/local/bin/ntpdate -bu -t 3 navobs1.gatech.edu /sbin/hwclock systohc The first line tells the system what command interpreter youre using: here its the bash shell, the standard Linux shell. The second line launches the ntpdate program and queries a time server at the Georgia Institute of Technology. If your university has its own time server, you should use it; otherwise consult a list of public ntp servers, like the one at http://www.eecis.udel.edu/~mills/ntp/clock1.htm. I suggest using a server that is in your country and in the same longitude. The third line uses the information received from the time server to set the computers hardware clock. Once youve typed the above, hit control-x to close pico. When you get back to the command prompt, you need to make the file you just created executable by issuing the following command: chmod 700 set-time The chmod command changes the files permissions so that your text file becomes a shell script; i.e., a program that you can execute. Once you change the permission, you can execute the file by typing its name: ./set-time The output should look something like this: 20 Jun 15:09:48 ntpdate[14312]: step time server 140.221.9.6 offset -0.002477 sec Finally, you want your server to run this script everyday to set its clock, so you will have to make an alias of the file in the /etc/cron.daily directory: cd /etc/cron.daily ln s /usr/local/sbin/set-time If you list the files in this directory, you should now see a symbolic link to your set-time shell script. As the directory name suggests, each file within the directory will be run everyday automatically by the server. Now your server should always be within milliseconds of the correct time. |